Support

Account

Home Forums ACF PRO New Attachment Field – Update images

Helping

New Attachment Field – Update images

    • sja

    • July 3, 2019 at 6:08 pm

    I have a page that uses an ACF gallery.
    I’ve also added a field to all image attachments called “gallery_size”.
    This offers the options of Small, Medium or Large via a radio button.
    My end goal is to use the size value to vary the width of the image in the gallery.

    I have the gallery working, I can loop through the images and grab their descriptions and the size value. That’s all good.

    The problem I have is that there are 300 images on the site and the “gallery_size” value is only becomes available if I open the image in the media gallery and update it.

    Is there any way to auto update all the images rather than me having to do this manually?

    Thanks in advance for any pointers!

    • James

    • July 15, 2019 at 8:58 pm

    Hi there,

    Thanks for getting in touch!

    You can workaround this issue by creating a custom foreach loop to step through all the gallery images and pass the field value to the update_field() function. The first parameter should be the field key as described on the following page: https://www.advancedcustomfields.com/resources/update_field/

    I hope this info helps. Thank you.

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

You must be logged in to reply to this topic.

We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Cookie Policy. If you continue to use this site, you consent to our use of cookies.