Home › Forums › Add-ons › Gallery Field › Gallery Field options per image › Reply To: Gallery Field options per image
Hi, I’m just checking threads for my own gallery customisation.
While I’m here can i suggest you can get the image ratio and then add classes accordingly as I’ve done.
My php is pretty basic but here’s how I used classes to set column width for my flex grid.
produces this output:
<div class=”image normal 1.5771428571429″>
<div class=”image wide 3.463687150838″>
<div class=”image tall 0.79714285714286″>
<div class=”image very-wide 8.1012658227848″>
if( $images ): ?>
<?php foreach( $images as $image ): ?>
<?php
$ratio_class = 'undefined';
$w = $image['width'];
$h = $image['height'];
$ratio = $w / $h;
switch (true){
case $ratio < 1 :
$ratio_class = "tall $ratio";
break;
case $ratio > 4 :
$ratio_class = "very-wide $ratio";
break;
case $ratio > 2 :
$ratio_class = "wide $ratio";
break;
default:
$ratio_class = "normal $ratio";
}
?>
<div class="image <?php echo $ratio_class; ?>">
I’m actually looking to add another button to the gallery editor thumbs. just like the delete x – but for a sold status on artworks.
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Privacy Policy. If you continue to use this site, you consent to our use of cookies.