Support

Account

Home Forums Add-ons Repeater Field Improve performance of images in repeater fields Reply To: Improve performance of images in repeater fields

  • I know it’s a bit old topic, but I have an idea. Not sure if it’s doable in the ACF but I did something similar in the past (not in wordpress). In order to fetch all images I created field media[] that was simply an array of all images/files used in the page. So when a user added an image I also added new field that stored the id to it:
    <input name="media[]" value="image_id">
    I then stored this field in database – which hold all the media connected to this particular page, and then just query images with the IN() in the frontend. This way I had only one query and not 20-30 depending on the amount of images/files connected to that page.

    In the backend I also used http://php.net/manual/en/function.array-unique.php to remove all duplicates in media array.

    I am not sure is this possible in ACF as I’m not very familiar with the ACF source code, but it could be a really good solution. Let me know your thoughts about it.

    I use this tool https://wordpress.org/plugins/query-monitor/ to see where I can have performance problems, and I have now 158 queries where 98 are ACF. And by looking what is it, it’s mostly images, as I have repeater for “partners”. Because there needs to be added URL I can’t use gallery for that.