Support

Account

Home Forums General Issues Image Field in Repeater not passing image URL to page

Solving

Image Field in Repeater not passing image URL to page

  • This is a problem I have been trying to debug for several days now to no avail. I am using a fieldset with a repeater that contains a handful of fields, one of which is an Image field that’s set to return the image URL (verified) to the page. (ACF Pro here.)

    I have written ACF repeater systems before with images just like this and no issue. But here, the system behaves as one would expect on my local dev setup and on one of our QA servers, but it does NOT render the image on our Staging or Production servers. These are setup identically, same plugins, etc. I am trying to determine why. In all cases, the images can be seen fine in WP admin.

    If I do a var_dump() on $myStruct = the_row() I see that the field is returning the post_id of the image. When I track that image down by hand, looking to match the ID, I find it — both on the servers where the image renders and where it does not.

    On servers where the image does not render, in HTML source the image URL is “”.

    I am against a wall here. Any suggestions welcome — not sure where to go from here. Thanks.

    ( I am registered for support under the email address bpatterson AT ncta DOT com, if it matters. )

  • I’ve made a simpler new page on the Staging server and it also does not show images in the repeater. They are there in the admin. Var_Dump included:

    if(have_rows('image_test_repeater')) :
        while(have_rows('image_test_repeater')) : $rowHold = the_row();
    
            var_dump($rowHold);
            
            echo("BEFORE");
            if(get_sub_field('test_image_file')) {
                echo("<img src='");
                the_sub_field('test_image_file');
                echo("'>'");
            }
            echo("AFTER");
    
        endwhile;
    endif;

    And out put is:

    array(1) { ["field_57c8633980573"]=> string(4) "2117" } !!BEFOREAFTERarray(1) { ["field_57c8633980573"]=> string(4) "2114" } !!BEFOREAFTER

    Those are the correct post_ids for the images, in the dump.

  • Try this and tell me what you get

    
    if(have_rows('image_test_repeater')) :
        while(have_rows('image_test_repeater')) : $rowHold = the_row();
    
            var_dump($rowHold);
            
            echo("BEFORE ");
            if(get_sub_field('test_image_file')) {
    						echo 'IMAGE EXISTS ID = '.get_sub_field('test_image_file');
                echo("<img src='");
                the_sub_field('test_image_file');
                echo("'>'");
            }
            echo(" AFTER");
    
        endwhile;
    endif;
    
  • I do not see the IMAGE EXSITS message — so the get_sub_field() function is evaluating negative. That is the field name, and note that on another server running the same code repository — THE IMAGE RENDERS.

    Maddening. Huge roadblock on this proj, sadly. Other ideas? Thanks.

  • I looked into the DB after the first field “name” in that var dump:

    postmeta image

    posts image

  • It’s hard troubleshooting this way, but as long as you’re willing to try out ideas.

    What’s hard to understand is why it would work correctly on one installation and not in the other if the two installations are identical. Something is off there. If everything really is identical then it should work in both places.

    How to you get content from the server where it is working to the server where it’s not working?

  • this is slightly different code to try

    
    if(have_rows('image_test_repeater')) :
        while(have_rows('image_test_repeater')) : $rowHold = the_row();
    
            var_dump($rowHold);
            
            echo("BEFORE ");
            if(get_sub_field('test_image_file', false, false)) {
    						echo 'IMAGE EXISTS ID = '.get_sub_field('test_image_file', false, false);
                echo("<img src='");
                the_sub_field('test_image_file');
                echo("'>'");
            }
            echo(" AFTER");
    
        endwhile;
    endif;
    
    
  • Thanks for the help.

    Still no output between BEFORE and AFTER. I will add that there is another custom fieldset in use on the Staging server where images are not serving in this code I am wrangling with that also uses an image in a repeater and it DOES work, DOES render.

    So that works, and two repeater field sets containing image fields written very shortly after the functional one on same server do not render. Still digging.

  • If this is producing nothing

    
    echo 'IMAGE EXISTS ID = '.get_sub_field('test_image_file', false, false);
    

    then there is no image ID in the field associated with the post.

    The ACF image field should have an attachment ID.

    what about
    echo get_post_meta($post->ID, 'test_image_field', false);

  • That returns (I see with a var_dump) an empty array:

    array(0) { }

    Is this something I can discover the source of browsing the tables? Thanks again.

  • So, the problem here is that the post on the one server does not have a value set for the image, but the other server does.

    This leads me back to a previous question. How are you getting the data from the server that is working to the server that is not? How are you moving the db content?

  • We are using Mercurial as a versioning system with BitBucket as the repo store. We work on a local dev in VBox and make changes (filesystem — plugins, WP updates, etc) in a branch there and push up to servers. We are not typically pushing content up (DB content), as now we are in a early build state.

    I’ve been thinking about this. It has been the case that in certain circumstances for testing we have likely pushed out an older branch, with an older ver of ACF and been prompted for a DB Update in WP Admin in going from ACF Pro to _earlier_ ACF + Repeater. I believe one of us have seen this promote and followed it on said servers (perhaps not all servers).

    Are you thinking what I’m thinking here? Ideas to resolve? Thank you.

  • I honestly don’t really have a clue at this point. It could be any number of things an I don’t even know where to start guessing. There must be some difference between the two installations that causes the data to not exist on one of them. As a starting place, either the value really does not exist for the post or maybe the field name is different and on the server where you’re seeing it missing ACF is storing in in one place while you’re trying to get it from another. After that I wouldn’t even know what direction to go in.

  • I am now trying to verify a consistent data / table structure. I see field name codes, but I am not finding the actual field name in any of the tables. Say I have a field inside a repeater named “My Field One” / “my_field_one” — where would I see that/those strings in the schema? Thanks.

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

The topic ‘Image Field in Repeater not passing image URL to page’ is closed to new replies.