Support » Plugin: Custom Content Shortcode » Limit the size of an image from ACF

  • How can I limit the size of these picture in this repeater code? I want to limit the height of the image. Most code examples I can find are modifying the url of the image html code, but in this repeater code in the page there is no html.
    I tried adding to the div style max_height:150 and it does limit the height of the div, but it crops the picture. I’d like the picture resized to fit.

    [repeater staff_listing]
    <div class="alignright">[if field=picture][field image=picture][/if]</div>
    <b>[field name]</b>
    [field title]
    [if field=email]<a href="mailto:[field email]">[field email]</a>[/if]
    <div style="clear: both;"></div>
    
    <hr />
    
    [/repeater]
Viewing 2 replies - 1 through 2 (of 2 total)
  • Did you try to add the size attribute to the image shortcode?

    You can pick the default sizes of WordPress (thumbnail, medium, large) or add a custom size.

    For example:
    [field image=picture size=thumbnail]

    After you add a custom image size, you have to regenerate the thumbnails for all images you’ve already uploaded (or only the images you want to use).

    An other option is to use CSS max-width and width: auto;.

    Peter

    Thank you, the size parameter to the field image worked great!

    I’m not sure how to use the css though in a shortocde if we were to use that method instead

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Limit the size of an image from ACF’ is closed to new replies.