can't view expanded images
See original GitHub issueAngular is sanitizing the active image view background-image style. Getting this any time I attempt to open the image for full size view:
“WARNING: sanitizing unsafe style value url(assets/img/gallery/…”
This is appearing for me on a fresh project, literally built just to test the gallery. Images go through graphicsmagick fine, and I’m getting all the thumbnails without issue (probably because they’re img tags, and the src isn’t getting set as a background style).
Otherwise the gallery looks and works great. Good work sir!
Was wondering if maybe you could just include a pipe into your template section where you inject the relative urls into the styles. I found this method, that seems like it should work
`import { Pipe } from ‘@angular/core’; import { DomSanitizer, SafeHtml, SafeStyle, SafeScript, SafeUrl, SafeResourceUrl } from ‘@angular/platform-browser’;
@Pipe({ name: ‘safe’ }) export class SafePipe {
constructor(protected _sanitizer: DomSanitizer) {
}
public transform(value: string, type: string = 'html'): SafeHtml | SafeStyle | SafeScript | SafeUrl | SafeResourceUrl {
switch (type) {
case 'html': return this._sanitizer.bypassSecurityTrustHtml(value);
case 'style': return this._sanitizer.bypassSecurityTrustStyle(value);
case 'script': return this._sanitizer.bypassSecurityTrustScript(value);
case 'url': return this._sanitizer.bypassSecurityTrustUrl(value);
case 'resourceUrl': return this._sanitizer.bypassSecurityTrustResourceUrl(value);
default: throw new Error(`Invalid safe type specified: ${type}`);
}
}
}`
Can simply be called by ‘whatever | safe: “style”’
For non-plagiarism’s sake - https://forum.ionicframework.com/t/inserting-html-via-angular-2-use-of-domsanitizationservice-bypasssecuritytrusthtml/62562/5
I wish you luck sir!
angular - ^4.0.0 node - 7.9.0
Issue Analytics
- State:
- Created 6 years ago
- Comments:11
Top GitHub Comments
Been a while since I worked on this, but you can see how I implemented the image viewer here. I cloned the repo and brought it into my project with some modifications. - https://github.com/ajnolte12/beta-sig-website/tree/master/src/app/gallery/image-gallery
Same for me, not working on a fresh Angular 6 project