This will return the link to the attachment:
$link=wp_get_attachment_link($image->ID);
However, I can’t find a way to get the LINK TO value from the ATTACHMENT DISPLAY SETTINGS of an image. See screenshot below.
This will return the link to the attachment:
$link=wp_get_attachment_link($image->ID);
However, I can’t find a way to get the LINK TO value from the ATTACHMENT DISPLAY SETTINGS of an image. See screenshot below.
You must be logged in to post a comment.
As yoavmatchulsky wrote, this field is dynamically filed by ~wp-includes/js/media-views.js after you manually choose an image
but if you have an id of attachment, use wp_get_attachment_link( $id, $size);
as size use ‘full’
full ref. in codex
Or, if you are trying to use a custom link, the method described here might help.
Basically, in your functions.php, you could add a code similar to this:
And then, you could call it in your php like so:
I know this is an old thread, but I solve this by getting the post meta of the attachment, which was easier to me.
In my installation, custom URL input is shown like this:
So, I assumed that if the first brackets contains the post ID, the second one is a meta key to save this value on wp_postmeta table. And there it was, just starting with the underscore character so it would be a hidden meta data. Therefore, the easier way to get this value is like this:
Of course you need to check if the post does have a thumbnail, but that’s easy to adapt.