WordPress.org

Ready to get started?Download WordPress

Forums

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

  1. radiofranky
    Member
    Posted 2 years ago #

    Hi,
    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!

    http://wordpress.org/extend/plugins/advanced-custom-fields/

  2. Joff Crabtree
    Member
    Posted 2 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!

    Cheers

    Joff

  3. bluzzzzy
    Member
    Posted 2 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
    Member
    Posted 2 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
    Member
    Posted 1 year ago #

    Priceless! Thanks so much joffcrabtree

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic

Tags

No tags yet.