Get full image URL from attachment (blog post teaser) for Open Graph metatag

Sean Lim asked on March 19, 2015 20:30

Hi, I'm trying to get the full image URL of a blog post teaser attachment so that I can dynamically load it in the og:image metatag for facebook sharing.

I've tried this in my head webpart: which returns just the GUID of the attachment: 4a2a5744-bb58-4440-a6dd-c2d8409b811d

and this: which returns this: /getattachment/4a2a5744-bb58-4440-a6dd-c2d8409b811d/Blog/December-2014/No-Coffee-Fetching-Allowed-Around-Here This does return the image, but I need the full URL with the .jpg extension (as per Facebook)

Thanks!

Recent Answers


Petar Kozjak answered on March 20, 2015 16:39

Hi,

I would recommend using Media Library. All files can be accessed as physical files.

0 votesVote for this answer Mark as a Correct answer

steve burleigh answered on May 8, 2015 00:31 (last edited on December 10, 2019 02:30)

Hi

Im having the same issue as this - the OG tag is currently set to

BUT

this generates the following URL

https://www.ice.org.uk~/ICEDevelopmentWebPortal/media/News/Membership/books-for-sale.jpg?ext=.jpg

How do i get rid of the '~'? If i remove the 'https://{% CurrentSite.SiteDomainName |(identity)GlobalAdministrator%}' i get the path minus the '~' but also minus the domain name

Any help would be gratefully received!

0 votesVote for this answer Mark as a Correct answer

   Please, sign in to be able to submit a new answer.