Home Forums Front-end Issues Very slow TTFB with repeater gallery Reply To: Very slow TTFB with repeater gallery

  • I know this is a couple or 3 months old and not sure if you found a resolution or not, but, I doubt a simple counter j=1; j+=1 would have anything to do with it. I would change it to j++, although that should not effect anything.

    The main issue is most likely the image and gallery fields returning the image arrays. The more image sizes you have on the site the slower this is going to be.

    When it comes to image fields, if you’re worried about performance, you are better off either returning just the ID for each image or getting the unformatted value from ACF and then using core WP functions to get the only the information you need about each image. The image array is going to have a lot of image data that you’ll never use.

    You can get unformatted data from ACF by supplying false as the 3rd argument get_field('field_name, false, false);` the second false gets values for the current post.

    use wp_get_attachment_image_src($image_id, $size); to get the image info.
    use get_post_meta($image_id, '_wp_attachment_image_alt', true); to get the alt text.
    use get_post_field('post_excerpt', $image_id); to get the caption