I'm using this script to get media items. There is an XSLT example with som regex where you insert "_thumb" before jpg. Does anyone know how to do that using razor in the example code below?
Thanks / Niklas
@foreach(dynamic d in Model.kollektion.mediaItem) { if (d.BaseElement.Name == "Image") { <img src="@d.umbracoFile" alt="@d.nodeName" /> } else { <img src="@d.Image.umbracoFile" alt="@d.Image.nodeName" /> } }
But instead I'd recommend you use Douglas Robars excellent ImageGen package. With that installed you can generate thumbnails in any size you wish like this:
How to get media thumbnail?
Hi
I'm using this script to get media items. There is an XSLT example with som regex where you insert "_thumb" before jpg. Does anyone know how to do that using razor in the example code below?
Thanks / Niklas
@foreach(dynamic d in Model.kollektion.mediaItem)
{
if (d.BaseElement.Name == "Image")
{
<img src="@d.umbracoFile" alt="@d.nodeName" />
}
else
{
<img src="@d.Image.umbracoFile" alt="@d.Image.nodeName" />
}
}
Hi Niklas
You could probably do it with a string operation like:
But instead I'd recommend you use Douglas Robars excellent ImageGen package. With that installed you can generate thumbnails in any size you wish like this:
Check out Douglas's documentation for further info, it's on the project page.
Regards
Jesper
thanks Jesper , works like a magic !
I know this is an old thread, but it helped me out. But I would recommend:
<img src="@(Regex.Replace(img.Url, "\\.(.*?)$", "_thumb.$1"))" />
As a png could be uploaded as well.
Hi,
Is it working for you? As I see Umbraco creates thumbs with jpg extension, even if the source is PNG.
Second. For small image files like 5kb Umbraco did NOT create thumb file.
is working on a reply...