Skip to content

Commit 5e2106e

Browse files
authored
update placeholder to use core (#289)
1 parent 43af48f commit 5e2106e

File tree

2 files changed

+2
-21
lines changed

2 files changed

+2
-21
lines changed

projects/angular-cld/src/lib/cloudinary-placeholder.component.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ import {
77
Renderer2,
88
} from '@angular/core';
99
import {Cloudinary} from './cloudinary.service';
10-
import { placeholderImageOptions, predominantColorTransformPxl } from './constants';
1110

1211
@Component({
1312
selector: 'cl-placeholder',
@@ -45,9 +44,9 @@ export class CloudinaryPlaceHolder implements AfterContentChecked {
4544

4645
getPlaceholderImage() {
4746
if (this.type === 'predominant-color' && this.itemHeight && this.itemWidth) {
48-
return this.cloudinary.url(this.publicId, {transformation: [this.options, ...predominantColorTransformPxl]});
47+
return this.cloudinary.url(this.publicId, {transformation: [this.options], placeholder: 'predominant-color-pixel' || true});
4948
} else {
50-
return this.cloudinary.url(this.publicId, {transformation: [this.options, ...(placeholderImageOptions[this.type] || placeholderImageOptions['blur'])]});
49+
return this.cloudinary.url(this.publicId, {transformation: [this.options], placeholder: this.type || true});
5150
}
5251
}
5352

projects/angular-cld/src/lib/constants.ts

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -5,21 +5,3 @@ export const accessibilityEffect = {
55
'colorblind': {effect: 'assist_colorblind'}
66
}
77

8-
export const predominantColorTransformPxl = [
9-
{width: 'iw_div_2', aspect_ratio: 1, crop: 'pad', background: 'auto'},
10-
{crop: 'crop', width: 1, height: 1, gravity: 'north_east'},
11-
{fetch_format: 'auto', quality: 'auto'}];
12-
13-
export const predominantColorTransform = [
14-
{variables: [['$currWidth', 'w'], ['$currHeight', 'h']]},
15-
{width: 'iw_div_2', aspect_ratio: 1, crop: 'pad', background: 'auto'},
16-
{crop: 'crop', width: 10, height: 10, gravity: 'north_east'},
17-
{width: '$currWidth', height: '$currHeight', crop: 'fill'},
18-
{fetch_format: 'auto', quality: 'auto'}];
19-
20-
export const placeholderImageOptions = {
21-
'vectorize': [{effect: 'vectorize:3:0.1', fetch_format: 'svg'}],
22-
'pixelate': [{effect: 'pixelate', quality: 1, fetch_format: 'auto'}],
23-
'blur': [{effect: 'blur:2000', quality: 1, fetch_format: 'auto'}],
24-
'predominant-color': predominantColorTransform
25-
};

0 commit comments

Comments
 (0)