Advanced Custom Fields
how to resize upload image? (5 posts)

  1. radiofranky
    Posted 4 years ago #

    I would like to resize the uploaded image to a thumbnail size 150x 120 to save host bandwidth, especially when uploaded file is huge 3000 x 3000.
    If I don't resize it, it will take forever to load(when I have 40 to display).

    I was wondering if there is a way to call the thumbnail image url instead of original image.

    Or any alternative way to reduce the size suggestions would greatly appreciated.

    Great plugin, i love it!


  2. Joff Crabtree
    Posted 4 years ago #

    Hey radiofranky,

    You need to know a couple of things first. The names of the image presets in WordPress (I think defaults are Thumbnail, Medium, Large and Full Size). You can always add your own.

    You also need to know the name of the custom field for your image. Try this below (replacing 'acf image field name' with your own field name obviously :P).

    <? if(get_field('acf image field name')):
    $attachment_id = get_field('acf image field name');
    echo wp_get_attachment_image( $attachment_id, medium); ?>
    <?php endif; ?>

    This will use the preset 'medium' size. Let me know how you get on!



  3. bluzzzzy
    Posted 4 years ago #

    I tried your code Joff but it is not working.

    get_field('acf image field name') returns the image url, not its id.

    Am I missing something?

  4. bluzzzzy
    Posted 4 years ago #

    Ahaa...! I've found the problem: I missed in the config tab for my image field that you could set the return value to URL or ID...

  5. adammontague
    Posted 3 years ago #

    Priceless! Thanks so much joffcrabtree

Topic Closed

This topic has been closed to new replies.

About this Plugin

  • Advanced Custom Fields
  • Frequently Asked Questions
  • Support Threads
  • Reviews

About this Topic


No tags yet.