GlassHtml.RenderImage does not render correct html when ImageParameters are supplied.

152 views
Skip to first unread message

Robert Gray

unread,
Jun 20, 2013, 12:10:37 AM6/20/13
to glass...@googlegroups.com
Hi, 

When I call GlassHtml.RenderImage(MyImage, new ImageParameters { Width = 100, Height = 100 })  I get the invalid markup w="100" h="100" , rather than valid markup width="100" height="100".
The parameters are supplied correclty the Sitecore Image handler (it exects w and h).  This is causing problems for me in Chrome.  The image is rendered ok in IE 10 & Firefox.  

For the time being I am calling this method still and using CSS to control my image size.  

Is it possible to have the RenderImage method output the correct and valid attribute names?  Also, it'd be great if, when no width and height parameters are supplied, the width and height img attributes are set to be the size of the actual image, as happens currently with the image field render in sitecore.

Lukasz R

unread,
Aug 8, 2014, 10:43:10 AM8/8/14
to glass...@googlegroups.com
Hi,

Can we have an update on this? I also have similar problem. I've this code

    var parameters = new ImageParameters { MaxWidth = (int)imageMode };
    parameters.Parameters[ResponsiveImages.DataAttributeName= ResponsiveImages.DataAttributeImage;
 
    var imageTag = glassHtml.RenderImage(modelfieldparametersisEditable);
    return new MvcHtmlString(imageTag);

The problem I have is when I pass any parameters like in the code above it ignores all of the parameters set by Sitecore (like language etc.) If I pass a null value as parameters than all those values are respected.

Lukasz R

unread,
Aug 11, 2014, 2:18:00 AM8/11/14
to glass...@googlegroups.com
OK, seems that in my case the problem was not Glass Mapper after all but a JS code that removed those parameters from image URLs.
Reply all
Reply to author
Forward
0 new messages