i able put image rails app, has static size. change size of image.
my current code is
<%= image_tag("logo.png", :alt => "rss feed") %> i though might work
<%= image_tag("logo.png", :alt => "rss feed", height="42" width="42") %> but doesn't.
you on right track! on rails view, want use hashes. reason why second example not work because looks height, new object, equal 42. instead, want height attribute of object, did alt text.
similar making new activerecord objects, want define attributes of image hash. when using image_tag, goes follows:
sometimes html attributes contain dash. not sure of how erb handles it, can rocket ship syntax, like: 'data-method' => :delete.
given example, line work best. allows height , width operate independently.
<%= image_tag("logo.png", alt: "rss feed", height: 42, width: 42) %> no need enter numbers string. automatically interpreted 42px when rendered. finally, has mentioned, best styling in css, since (i assuming) size being used on 1 image, okay (imo).
Comments
Post a Comment