Support

Account

Home Forums ACF PRO Gallery width and height attributes?

Helping

Gallery width and height attributes?

  • I solved it!

    Hello! I have tried to find a way to add the width and height to the images in a ACF gallery. But it doesn´t call any values of the chosen size medium-height.
    Everything except that works. The Alt text is rendered/ displayed.

    What I´m I missing?
    I missed to define $size.
    $size = ‘medium-height’;

    
    <?php 
    	
    	$images = get_field('artist_galleri');
    	
    	if( $images ): ?>
    	    
    	    <ul class="image-galleri">
    	        <?php foreach( $images as $image ): ?>
    	           <div id="artist-galleri"> 
    	            <li>
    	                <a href="<?php echo $image['url']; ?>">
    		                
    	                     <div class="maxh"><img src="<?php echo $image['sizes']['medium-height']; ?>" width="<?php echo $image['sizes'][ $size . '-width' ]; ?>" height="<?php echo $image['sizes'][ $size . '-height' ]; ?>" alt="<?php echo $image['alt']; ?>" ></div>
    	                     	                     	                     
    	                  	                     
    	                </a>  
    	            </li>
    	           </div>
    	        <?php endforeach; ?>
    	    </ul>
    	    
    	<?php endif; ?>
    
  • Thanks for posting the solution to your problem. This will probably help others.

    ~JH

Viewing 2 posts - 1 through 2 (of 2 total)

The topic ‘Gallery width and height attributes?’ is closed to new replies.