Missing dimensions on Media after uSync #14170
netcompany-runeviumsondergaard
started this conversation in
Features and ideas
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Hello
I am using uSync to sync both content and media across my instances of Umbraco (and moving the wwwroot with the actual images in). Unfortunately it seems that the umbracoWidth, umbracoHeight etc. is not updated automatically, and will only be set after pushing the save button.
To handle this I made an UpdateMediaDimensionsHandler which looks through the media files and updates the images when the application is fully started and only on the first boot. It is tested on Umbraco 11.
The handler is added in the startup as a notification handler:
.AddNotificationHandler<UmbracoApplicationStartedNotification, UpdateMediaDimensionsHandler>()
I don't know if this should really be a bug reported to Umbraco or uSync, but now there is a fix which possible could become part of Umbraco :)
Code:
using Umbraco.Cms.Core;
using Umbraco.Cms.Core.Events;
using Umbraco.Cms.Core.Models;
using Umbraco.Cms.Core.Notifications;
using Umbraco.Cms.Core.Services;
using Umbraco.Cms.Infrastructure.Scoping;
namespace UmbracoPOC.Handlers;
public class UpdateMediaDimensionsHandler : INotificationHandler
{
private readonly IKeyValueService _keyValueService;
private readonly IMediaService _mediaService;
private readonly IMediaTypeService _mediaTypeService;
private readonly IScopeProvider _scopeProvider;
}
Beta Was this translation helpful? Give feedback.
All reactions