Support

Account

Home Forums General Issues image is not shown in acf

Solving

image is not shown in acf

  • hey community,

    I created a template for my CPT’s, which I feed using acf.
    in future, all content should be updated / added by importing a csv file.

    In my “old” template I have integrated an image with the following code:

    		<div class="druckerimage">
    			<?php $image = get_field('image');
    				if( !empty($image) ): ?>
    					<figure class="gesamt">
    						<img src="<?php echo $image['url']; ?>" alt="<?php echo $image['alt']; ?>" class="druckerimg"/>
               				<figcaption><?php echo $image['description']; ?></figcaption>
    
          				</figure>
    
    			<?php endif; ?>
    		</div>

    if I add my contribution / post “normally” using the traditional method, then my image, which I have added in the Metabox, will also be displayed sensibly.
    But if I try the whole thing via the import, the image will be displayed in the metabox (image array), but neither in the template nor in the source code ….

    https://ibb.co/SJsbPXj

    do I have to work with a different field type here? Or use a different return value?

    So far, to add my picture, I did the following:
    I upload the image manually via directly via WordPress. Then I copy the image URL into my csv file.

  • okay i think i found the bug.
    I have now selected “Single-line text” as the field type for the import.

    <?php if( get_field('image') ): ?>
        <img src="<?php the_field('image'); ?>" />
    <?php endif; ?>

    So the picture is now also shown to me.

    I think I will now add an “if query” to ask whether an image is “uploaded” as text, or in the traditional way using the field type “image”.

    Or are there suggestions for improvement?

  • The problem is that when you do the import the field key reference to the image field is not created. See the section about updating fields by field key here https://www.advancedcustomfields.com/resources/update_field/

    Whatever you’re using to do the import needs to be aware of ACF and create the correct field key references.

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

You must be logged in to reply to this topic.