Provide source Url for OEmbedPart as MediaUrl (#8249)

Fixes #8242
This commit is contained in:
Matteo Piovanelli
2019-07-25 21:08:53 +02:00
committed by Sébastien Ros
parent 906ee6fe0c
commit 4d04dcc5bb

View File

@@ -40,8 +40,15 @@ namespace Orchard.MediaLibrary.Handlers {
OnRemoving<MediaPart>((context, part) => RemoveMedia(part));
OnLoaded<MediaPart>((context, part) => {
if (!String.IsNullOrEmpty(part.FileName)) {
if (!string.IsNullOrEmpty(part.FileName)) {
part._publicUrl.Loader(() => _mediaLibraryService.GetMediaPublicUrl(part.FolderPath, part.FileName));
} else {
// Usually, OEmbedParts won't directly have a source file, but we may be interested
// in easily accessing their source Url.
var oePart = part.As<OEmbedPart>();
if (oePart != null) {
part._publicUrl.Loader(() => oePart.Source);
}
}
});