Home Forums General Issues ACF Image – Img Src Unknown – Image not showing


ACF Image – Img Src Unknown – Image not showing

  • Hi there,

    I’m a bit of a noob to this plugin, but am having some issues showing the an image from a custom field.

    The field is registered, the image is uploading fine, but when I`m trying to display the image I get :
    <img src=”” style=”display: block;”>

    It isn’t returning the URL.

    My call is:

    <img src="<?php the_field('footer_1_1'); ? />" />

    and my field is registered as follows:

    Any help appreciated

  • Is the image field for a post, term or options page?

  • It is for a custom post type.

  • Sorry, should have been more clear. I need more information on the field/field group. Where do the location rules say the field group appears. Where in the code of your template are you trying to get the value? For that matter, what type of template are you trying to get the value in (archive? single?)?

    Is the field where you add the image on a post editor page for his custom post type?

    If it is, is the call <img src="<?php the_field('footer_1_1'); ? />" /> inside “The Loop”

  • Oh wow. The mention of The Loop is definitely my issue.

    The location is “if Post equal to Footer Logo” (my custom post type)

    I am actually trying the pull the field data from inside of a PHP widget (located in my footer).

    Now that you have mentioned The Loop I realize how silly this is. I’m a beginner, forgive me.

    How can I go about calling the field from a location such as a footer widget?

  • You need to know the post ID of the post where the image is saved.

    From your description I’m not sure how you’d go about getting that ID.

    You then tell ACF where to get the value from

    <img src="<?php the_field('footer_1_1', $post_id); ? />" />
  • <img src="<?php the_field('footer_1_1', 3061 ); ? />" />

    Gives me a syntax error:

    Parse error: syntax error, unexpected '?' in F:\wamp64\www\esprit\wp-content\plugins\php-code-widget\execphp.php(27) : eval()'d code on line 3

  • I just copied your code and added the post id bit. Looks like there’s some things missing

    <img src="<?php the_field('footer_1_1', $post_id); ?>" />
  • Ahhh I got it working with:

    <img src="<?php the_field('footer_1_1', 3061); ?>" />

    I think I had a character issue on my keyboard (always switches languages randomly)

    Thank you so much for solving this!

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

The topic ‘ACF Image – Img Src Unknown – Image not showing’ is closed to new replies.