Piranha.core: AbsoluteContentUrl doesn't produce correct output for og:image tag

Created on 19 Mar 2021  路  4Comments  路  Source: PiranhaCMS/piranha.core

Hi all,
This is a new issue based on a discussion from https://github.com/PiranhaCMS/piranha.core/issues/1312.
Is seems that the AbsoluteContentUrl function doesn't produce the correct output for the og:image tag rendered from the PiranhaHtmlExtensions class.

As @StephenWRogers mentioned in #1312 :

It looks to me like

AbsoluteUrlStart will be

https://<-siteurl->

and ContentUrl will be

https://<-image blob url->

which AbsoluteContentUrl appends together

In my case the og:image is produced as:
http://localhost:5000https://xxx.s3.eu-west-1.amazonaws.com/xxx.jpg

For now I have overwritten the public static HtmlString MetaTags method locally for a quick fix, all I had to do was change
sb.AppendLine($"<meta property=\"og:image\" content=\"{ app.AbsoluteContentUrl(content.OgImage) }\">");
to:
sb.AppendLine ($"<meta property=\"og:image\" content=\"{app.ContentUrl (content.OgImage)}\">");

bug core

Most helpful comment

This has now been fixed in master and will be released in SR 1

All 4 comments

I'm experiencing the same issue.

<meta name="og:image" value="http://geekcafe.comhttps://cdn-media.geekcafe.com/799a39f6-adf7-4136-8a23-989b13be9a03/bird-s-eye-view-photography-of-lighted-city-3573383.jpg">

So the issue here is that the helper method assumes that the ContentUrl is a relative url, since this is what the FileStorage provider produces, but since external storage providers (like BlobStorage) always produces an absolute url. The solution here would be to check if the ContentUrl starts with http or not.

This has now been fixed in master and will be released in SR 1

Thanks @tidyui !

Was this page helpful?
0 / 5 - 0 ratings

Related issues

tidyui picture tidyui  路  6Comments

jcphlux picture jcphlux  路  4Comments

tidyui picture tidyui  路  6Comments

aneff-official picture aneff-official  路  4Comments

codesoroush picture codesoroush  路  6Comments