Skip to content

Commit d0c321f

Browse files
Social media platforms need scheme to detect images properly
1 parent 1d2bb5b commit d0c321f

File tree

1 file changed

+15
-15
lines changed

1 file changed

+15
-15
lines changed

src/Presentation/SmartStore.Web/Views/Product/Partials/Product.Picture.cshtml

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -3,22 +3,22 @@
33
@using SmartStore.Web.Models.Catalog;
44

55
@{
6-
Html.AddScriptParts("~/bundles/smart-gallery");
7-
var defaultPicture = Model.DefaultPictureModel;
6+
Html.AddScriptParts("~/bundles/smart-gallery");
7+
var defaultPicture = Model.DefaultPictureModel;
88

9-
// FB OpenGraph og:image & Twitter meta
10-
var oImg = Model.PictureModels?.FirstOrDefault();
11-
if (oImg != null && oImg.FullSizeImageUrl.HasValue())
12-
{
13-
var url = WebHelper.GetAbsoluteUrl(oImg.FullSizeImageUrl, this.Request);
14-
Html.AddCustomHeadParts("<meta property='twitter:image' content='{0}' />".FormatInvariant(url));
15-
Html.AddCustomHeadParts("<meta property='og:image' content='{0}' />".FormatInvariant(url));
16-
if (oImg.FullSizeImageWidth > 0 && oImg.FullSizeImageHeight > 0)
17-
{
18-
Html.AddCustomHeadParts("<meta property='og:image:width' content='{0}' />".FormatInvariant(oImg.FullSizeImageWidth.Value));
19-
Html.AddCustomHeadParts("<meta property='og:image:height' content='{0}' />".FormatInvariant(oImg.FullSizeImageHeight.Value));
20-
}
21-
}
9+
// FB OpenGraph og:image & Twitter meta
10+
var oImg = Model.PictureModels?.FirstOrDefault();
11+
if (oImg != null && oImg.FullSizeImageUrl.HasValue())
12+
{
13+
var url = WebHelper.GetAbsoluteUrl(oImg.FullSizeImageUrl, this.Request);
14+
Html.AddCustomHeadParts("<meta property='twitter:image' content='{0}:{1}' />".FormatInvariant(this.Request.Url.Scheme, url));
15+
Html.AddCustomHeadParts("<meta property='og:image' content='{0}:{1}' />".FormatInvariant(this.Request.Url.Scheme, url));
16+
if (oImg.FullSizeImageWidth > 0 && oImg.FullSizeImageHeight > 0)
17+
{
18+
Html.AddCustomHeadParts("<meta property='og:image:width' content='{0}' />".FormatInvariant(oImg.FullSizeImageWidth.Value));
19+
Html.AddCustomHeadParts("<meta property='og:image:height' content='{0}' />".FormatInvariant(oImg.FullSizeImageHeight.Value));
20+
}
21+
}
2222
}
2323

2424
<div id="pd-gallery-container-inner">

0 commit comments

Comments
 (0)