Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix opengraph image not working correctly #155

Merged
merged 1 commit into from
Feb 2, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,11 @@ public object Convert(object value, IPublishedContent currentContent, string fie
{
if (!settings.SupportedMediaTypes.Contains(Path.GetExtension(item.Url()), StringComparer.InvariantCultureIgnoreCase)) continue;

if (string.IsNullOrWhiteSpace(settings.OpenGraphCropAlias)) return item.GetCropUrl(urlMode: UrlMode.Absolute);
if (string.IsNullOrWhiteSpace(settings.OpenGraphCropAlias)) return item.Url(mode: UrlMode.Absolute);

var crops = item.Value<ImageCropperValue>("umbracoFile");
if (crops?.HasCrop(settings.OpenGraphCropAlias) is true) return item.GetCropUrl(settings.OpenGraphCropAlias, UrlMode.Absolute);
return item.GetCropUrl(urlMode: UrlMode.Absolute);
return item.Url(mode: UrlMode.Absolute);
}

return item.Url(mode: UrlMode.Absolute);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
using SeoToolkit.Umbraco.Common.Core.Services.SettingsService;
using SeoToolkit.Umbraco.MetaFields.Core.Config.Models;
using System.Linq;
using static Umbraco.Cms.Core.Constants.HttpContext;
using Umbraco.Cms.Core.PropertyEditors.ValueConverters;

namespace SeoToolkit.Umbraco.MetaFields.Core.Common.Converters.SeoValueConverters
{
Expand All @@ -30,7 +32,11 @@ public object Convert(object value, IPublishedContent currentContent, string fie
{
if (!settings.SupportedMediaTypes.Contains(Path.GetExtension(content.Url()), StringComparer.InvariantCultureIgnoreCase)) return null;

return string.IsNullOrWhiteSpace(settings.OpenGraphCropAlias) ? content.GetCropUrl(urlMode: UrlMode.Absolute) : content.GetCropUrl(settings.OpenGraphCropAlias, UrlMode.Absolute);
if (string.IsNullOrWhiteSpace(settings.OpenGraphCropAlias)) return content.Url(mode: UrlMode.Absolute);

var crops = content.Value<ImageCropperValue>("umbracoFile");
if (crops?.HasCrop(settings.OpenGraphCropAlias) is true) return content.GetCropUrl(settings.OpenGraphCropAlias, UrlMode.Absolute);
return content.Url(mode: UrlMode.Absolute);
}

return content.Url(mode: UrlMode.Absolute);
Expand Down