You can replace (or add srcset attributtes) by replacing $img['url'] with $img['sizes']['large'], $img['sizes']['small'], etc.
If you wanted to use it actually in a post (as in within the WP editor), your best bet would likely be to create a shortcode in your theme’s functions.php, which I expect would look something like the following:
Thank you for your answer but I think your solution does not help with my problem.
I expressed myself a bit awkwardly…sorry.
I have added a custom field to the file attachments (images) which can be filled out. (like the image alt attribute, description, title…)
The pictures are inserted in the text via the normal WYSIWYG editor. If the image has a description, I get it automatically (in the editor). Now I want the text of my custom field to be printed below the description (this should have an span around it or something).
I suspect I can only solve this via functions.php?
Viewing 3 posts - 1 through 3 (of 3 total)
The topic ‘show custom field for media (img) in theme’ is closed to new replies.
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users