Skip to content

Commit

Permalink
Merge pull request #3 from nickh364/master
Browse files Browse the repository at this point in the history
Added mediapicker3 support
  • Loading branch information
dinc5150 authored Jun 24, 2021
2 parents 6b41f04 + c4810bd commit 2e91dca
Showing 1 changed file with 12 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -232,18 +232,26 @@ angular.module("umbraco")
if (typeof properties[p].value !== "undefined" && properties[p].value !== "" && properties[p].value !== null) {
//Found a fallback property value
console.log("fallback", properties[p])
$scope.model.value.shareImage = properties[p].value;
$scope.model.value.shareImage = properties[p];


if ($scope.model.value.shareImage != null && $scope.model.value.shareImage.startsWith("umb://")) {
if ($scope.model.value.shareImage.view == "mediapicker" && $scope.model.value.shareImage.value != null && $scope.model.value.shareImage.value.startsWith("umb://")) {
//The fallback is a media picker
entityResource.getById($scope.model.value.shareImage.value, "Media")
.then(function (mediaEntity) {
$scope.model.value.shareImageUrl = mediaEntity.metaData.MediaPath;
});
} else if ($scope.model.value.shareImage.view == "mediapicker3" && $scope.model.value.shareImage.value.length > 0) {
//The fallback is a media picker
$scope.model.value.shareImage = properties[p].value[0].mediaKey
entityResource.getById($scope.model.value.shareImage, "Media")
.then(function (mediaEntity) {
console.log(mediaEntity);
$scope.model.value.shareImageUrl = mediaEntity.metaData.MediaPath;
});
} else if ($scope.model.value.shareImage.startsWith("/")) {
} else if ($scope.model.value.shareImage.value.startsWith("/")) {
//Probably an upload field. Could be another random property too, so be careful
$scope.model.value.shareImageUrl = $scope.model.value.shareImage;
$scope.model.value.shareImageUrl = $scope.model.value.shareImage.value;
} else {
//Not a property with a valid source image
$scope.model.value.shareImageUrl = null;
Expand Down

0 comments on commit 2e91dca

Please sign in to comment.