Developer forum

Forum » Templates » Images in razor master template

Images in razor master template

Heine Virenfeldt Kristensen
Reply

Has created an item for website propeties, works fine execpt images/files.

Getting the image with GetString:

<img src="@GetString("Item.Area.NORRIQ_Logo")" width="156" height="58" alt="NORRIQ - Your business simplified" />

This gives me this, when viewing the page:

<img src="/Files/Templates/Designs/niq/"="" width="156" height="58" alt="NORRIQ - Your business simplified">

An alternative, with image as a variable:

<img src="@logo" width="156" height="58" alt="NORRIQ - Your business simplified" />

Gives this result:

<img src="/Files/Templates/Designs/niq//Files/Images/logo/logo.png" width="156" height="58" alt="NORRIQ - Your business simplified">

Any advice, what am I doing wrong?

 


Replies

 
Mikkel Ricky
Reply

In layout templates you should always use single quotes around attribute values containg double quotes, e.g.

<img src='@GetString("Item.Area.NORRIQ_Logo")' width="156" height="58" alt="NORRIQ - Your business simplified" />

Or, alternatively, use a Razor variable as you've done.

However – as you've noticed – this does not solve the issue. It's a bug (#15608) and we'll fix it.

As a temporary workaround you can use this in your layout template:

@("<")img src='@GetString("Item.Area.NORRIQ_Logo")' width="156" height="58" alt="NORRIQ - Your business simplified" /@(">")

 

It's not pretty, but it works!

Best regards,
Mikkel

 

You must be logged in to post in the forum