Merge pull request #8715 from umbraco/v8/bugfix/block-catalouge-use-absolute-path-and-dont-scale-svg

8.7RC umb-block-card absolute path and dont scale SVGs
This commit is contained in:
Warren Buckley
2020-08-26 08:09:59 +01:00
committed by GitHub
2 changed files with 31 additions and 2 deletions

View File

@@ -1,5 +1,5 @@
<div class="__showcase" ng-style="{'background-color':vm.blockConfigModel.backgroundColor, 'background-image': vm.blockConfigModel.thumbnail ? 'url('+vm.blockConfigModel.thumbnail+'?upscale=false&width=400)' : 'transparent'}">
<div class="__showcase" ng-style="{'background-color':vm.blockConfigModel.backgroundColor, 'background-image': vm.styleBackgroundImage}">
<i ng-if="vm.blockConfigModel.thumbnail == null && vm.elementTypeModel.icon" class="__icon {{ vm.elementTypeModel.icon }}" ng-attr-style="{{'color:'+vm.blockConfigModel.iconColor+' !important'}}" aria-hidden="true"></i>
</div>
<div class="__info">

View File

@@ -14,9 +14,38 @@
}
});
function BlockCardController() {
function BlockCardController($scope, umbRequestHelper) {
var vm = this;
vm.styleBackgroundImage = "none";
var unwatch = $scope.$watch("vm.blockConfigModel.thumbnail", (newValue, oldValue) => {
if(newValue !== oldValue) {
vm.updateThumbnail();
}
});
vm.$onInit = function () {
vm.updateThumbnail();
}
vm.$onDestroy = function () {
unwatch();
}
vm.updateThumbnail = function () {
if (vm.blockConfigModel.thumbnail == null || vm.blockConfigModel.thumbnail === "") {
vm.styleBackgroundImage = "none";
return;
}
var path = umbRequestHelper.convertVirtualToAbsolutePath(vm.blockConfigModel.thumbnail);
if (path.toLowerCase().endsWith(".svg") === false) {
path += "?upscale=false&width=400";
}
vm.styleBackgroundImage = 'url(\''+path+'\')';
}
}