Hi, can someone help me with this. How to with ACF plugin display alt or some other text on image. example. I have news portal with a number of posts and we often download imgs from other websites and we want to display small grey box in left corner of image with text like “Source of image”….
This is really a basic WP/HTML/CSS/Design question and does not relate to ACF specifically.
I suggest you look for coding techniques for doing what you want to do and for WP coding tips.
If you are using an image field https://www.advancedcustomfields.com/resources/image/ or a gallery field https://www.advancedcustomfields.com/resources/gallery/ there is documentation on the values you can from these fields.
If you have specific code that you need help with that relates to ACF you can post that and someone can try to help.
What @hube2 means is your basically asking a 2 part question.
#1 – How to pull the relevant data / text per image.
#2 – How to visually display the above data / text on each image in a small box giving credit to the original source.
With #1 he linked you to how (with writing some simple code) you could pull the data / text you need from the image.
This is the kind of help you would get from this site / forum. When you go on to ask for #2 specific “design” help also, then you would look for that kind of “specific” help from a site / forum where they concentrate on that.
So, once you atleast try #1 and post back here your code where you atleast tried, then someone could probably help you the rest of the way.
In your case, it would be more difficult to try and pull “the image’s source credit info” from the image itself.
Why not just create custom field(s) for each image?
News Article Image Name – Custom field for the image upload.
News Article Text Source – Custom field for the text you want to use inside the box.
News Article URL Source – Which is a url custom field to the source website / page.
Then on your page, in a DIV (you will have to determine your CSS styling)..
1. set the background image of the DIV to the image from the News Article Image Name custom field.
2. create an inner div, set that to absolute position (lower left) and use the News Article Text Source custom field
3. set that inner div’s hyperlink to News Article URL Source custom field.
I have created an extra field for image descriptions (image_description)
the whole thing is integrated with me with <figcaption>
<div class="druckerimage"> <?php $image = get_field('image'); if( !empty($image) ): ?> <figure class="gesamt"> <img src="<?php the_field('image'); ?>" alt="<?php the_field( 'modell' ); ?>" class="druckerimg" /> <figcaption><?php the_field( 'image_description' ); ?></figcaption> </figure> <?php endif; ?> </div>
maybe this will help you?!?
For your situation, it would be more hard to attempt to pull “the picture’s source credit information” from the actual picture. Why not simply make custom field(s) for each picture?
I recommend you search for coding methods for doing what you need to do and for WP coding tips.
You must be logged in to reply to this topic.
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
© 2022 Advanced Custom Fields.