use absolute path for thumbnail and dont scale SVGs

This commit is contained in:
Niels Lyngsø
2020-08-24 21:38:36 +02:00
parent 268eca922f
commit 056a554875
2 changed files with 32 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-style="{'color':vm.blockConfigModel.iconColor}" aria-hidden="true"></i>
</div>
<div class="__info">

View File

@@ -14,9 +14,39 @@
}
});
function BlockCardController() {
function BlockCardController($scope, umbRequestHelper) {
var vm = this;
vm.styleBackgroundImage = "transparent";
var unwatch = $scope.$watch("vm.blockConfigModel.thumbnail", (newValue, oldValue) => {
console.log("updateThumbnail")
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 = "transparent";
return;
}
var path = umbRequestHelper.convertVirtualToAbsolutePath(vm.blockConfigModel.thumbnail);
if (path.toLowerCase().endsWith(".svg") === false) {
path += "?upscale=false&width=400)";
}
vm.styleBackgroundImage = 'url(\''+path+'\')';
}
}