Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Rails image_tag width attribute to use a percentage / auto value?

image_tag('batman.png' size:'100%xauto')

The size 100% x Auto is ignored as it does not follow the convention outlined in the Rails API.

Is there a way to do this in rails without the need of a global / specific css class?

like image 635
Xavier Avatar asked Jun 07 '15 12:06

Xavier


1 Answers

size is spitted across the 'x' and on both side it finds for numbers. checkout the code You can use 'style' option for image_tag.

UPDATE:

You can use the image tag with style as followed

= image_tag 'image_url', style: 'height:100%;width:auto;'
like image 125
raviture Avatar answered Sep 21 '22 01:09

raviture