0
votes

I am working on a WordPress site that uses ACF (Advanced Custom Fields) to display a custom slider gallery. Problem is, I can't seem to get it to display custom image sizes within the slider.

In ACF the field type that is being used is content -> Gallery, I am then using the following code within my theme files:

<?php
    $images = get_field( 'slider' );
    $size = "archive-slider";
    if( ! empty( $images ) ) :
?>

<ul class="rslides">
    <?php
        foreach( $images as $key => $value )
        {
          echo '<li><img src="' . $value['url'] . '" /></li>';
        }
    ?>
</ul>

<?php endif; ?>

I have defined the custom image size in the functions file and regenerated the thumbnails but I can't get the size attribute to work.

Update

I updated my code to (this works):

<li>
    <img src="<?php echo $image['sizes']['archive-slider']; ?>" alt="<?php echo $image['alt']; ?>" />
</li>
1

1 Answers

2
votes

Per http://www.advancedcustomfields.com/resources/gallery/

You should be able to access the custom image size via $value['sizes']['custom-image-size']