Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

can't view expanded images

See original GitHub issue

Angular 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 -

I wish you luck sir!

angular - ^4.0.0 node - 7.9.0

Issue Analytics

  • State:open
  • Created 6 years ago
  • Comments:11

github_iconTop GitHub Comments

adamnoltecommented, Aug 10, 2018

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. -

Izzatbekcommented, Aug 4, 2018

Same for me, not working on a fresh Angular 6 project

Read more comments on GitHub >

github_iconTop Results From Across the Web

Can't see image in CONTENTdm item's expanded view
You get no image when you click the box with two arrows on the CONTENTdm detailed page for an item in a restricted...
Read more >
I can't tap pictures on Google Images?...
Last night, I found that when I tried to tap images on Google Images, they would not enlarge like usual. All of the...
Read more >
Can no longer click on images to expand in Image search ...
Can no longer click on images to expand in Image search, also can't click MORE or TOOLS at the top of search results....
Read more >
Can see thumbnails, but can't enlarge a photo
One of them is when enlarging a photo. I can see the thumbnail, but can't enlarge it. This is not happening to all...
Read more >
Instagram Tests New Option to View Expanded Profile Image ...
That could be handy for those times when the users' profile image is so small that you can't quite make out if it's...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Post

No results found

github_iconTop Related Hashnode Post

No results found