Support

Account

Home Forums Add-ons Flexible Content Field Flexible Content Image Sizes

Solved

Flexible Content Image Sizes

  • I’m new to using the flexible content add-on and totally loving it. Elliot, amazing work!

    I need to specify an image size for an image field (specifically ‘medium’) but am not sure how to go about that. Here’s the code for my image field:

    elseif( get_row_layout() == 'images' ):
    				
    	$image = get_sub_field('image');
    	echo '<img src="' . $image['url'] . '" alt="' . $image['alt'] . '" />';
    				
    endif;

    Can anyone tell me how to include an image size in the above? I’ve looked at examples online for selecting image sizes but I don’t know how to do it for a flexible content sub-field.

    Thanks in advance!

  • Hi @dadra

    This can be achieved no different to that of a regular field:
    http://www.advancedcustomfields.com/resources/field-types/image/

    You can echo a size like so:
    echo '<img src="' . $image['sizes']['thumbnail'] . '" alt="' . $image['alt'] . '" />';

  • Ah hah! That did it. Thanks so much Elliot.

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

The topic ‘Flexible Content Image Sizes’ is closed to new replies.