Support

Account

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.