image_tag(source, options = {}) Ok, when I want to use an image I added the following code: <%= image_tag "dsf.jpg" options = {[align="right", style="padding-right: 10px; padding-top: 5px;"]} %> However, this doesn''t seem to work, it doesn''t like how I have the "options" part setup. I''m sure there is something very easy I neglected. Thanks for any help on this. -- Posted via http://www.ruby-forum.com/.
On Dec 15, 2005, at 7:24 PM, Mark Haliday wrote:> image_tag(source, options = {}) > > Ok, when I want to use an image I added the following code: > > <%= image_tag "dsf.jpg" options = {[align="right", style="padding- > right: > 10px; padding-top: 5px;"]} %> > > However, this doesn''t seem to work, it doesn''t like how I have the > "options" part setup. I''m sure there is something very easy I > neglected. > > Thanks for any help on this. > > -- > > _______________________________________________ > Rails mailing list > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails >You need to loose the array inside your options hash I believe: <%= image_tag "dsf.jpg" options = {align="right", style="padding- right: 10px; padding-top: 5px;"} %> Cheers- -Ezra Zygmuntowicz WebMaster Yakima Herald-Republic Newspaper ezra-gdxLOakOTQ9oetBuM9ipNAC/G2K4zDHf@public.gmane.org 509-577-7732
<newbie warning (I am being self referencing here)> I believe that you should replace ''the options='' with a comma, you don''t need the curly braces despite them using them in the documentation and if options had been something you would use, it would have been a symbol ie :options and then it would be => rather than Other than that, I am not sure that you can put align="right" in an image. I think it would have to be outside the image. In any case, I''d use css as it is the morally right thing to do (I believe it saves trees) and so your line might end up looking like this: >%=image_tag("dsf.jpg", :class=>''my_image_class'') </newbie warning> bruce On 15-Dec-05, at 8:24 PM, Mark Haliday wrote:> image_tag(source, options = {}) > > Ok, when I want to use an image I added the following code: > > <%= image_tag "dsf.jpg" options = {[align="right", style="padding- > right: > 10px; padding-top: 5px;"]} %> > > However, this doesn''t seem to work, it doesn''t like how I have the > "options" part setup. I''m sure there is something very easy I > neglected. > > Thanks for any help on this. > > -- > Posted via http://www.ruby-forum.com/. > _______________________________________________ > Rails mailing list > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails
On Dec 15, 2005, at 8:59 PM, Ezra Zygmuntowicz wrote:> > On Dec 15, 2005, at 7:24 PM, Mark Haliday wrote: > >> image_tag(source, options = {}) >> >> Ok, when I want to use an image I added the following code: >> >> <%= image_tag "dsf.jpg" options = {[align="right", style="padding- >> right: >> 10px; padding-top: 5px;"]} %> >> >> However, this doesn''t seem to work, it doesn''t like how I have the >> "options" part setup. I''m sure there is something very easy I >> neglected. >> >> Thanks for any help on this. >> >> -- >> >> _______________________________________________ >> Rails mailing list >> Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org >> http://lists.rubyonrails.org/mailman/listinfo/rails >> > > You need to loose the array inside your options hash I believe: > > > <%= image_tag "dsf.jpg" options = {align="right", style="padding- > right: 10px; padding-top: 5px;"} %>Actually thats wrong, try this instead: <%= image_tag "dsf.jpg", :options => {:align=>"right", :style=>"padding-right: 10px; padding-top: 5px;"} %> Cheers- -Ezra Zygmuntowicz WebMaster Yakima Herald-Republic Newspaper ezra-gdxLOakOTQ9oetBuM9ipNAC/G2K4zDHf@public.gmane.org 509-577-7732
karthikeyan manivasagam
2012-Dec-17 06:55 UTC
Re: Question: image_tag(source, options = {})
Use the options directly in image tag as how you use in html tag,but little convertion has to be done for Rails code, it will work HTML : <img alt="logo" src="logo.png" align="right" style="background-color:#288AC6; padding:10px;" class="classname" id="idname" /> RAILS : <%= image_tag(''logo.png'', :alt=>''logo'',:align=>''right'' ,:style=>''background-color:##288AC6; padding:10px;'' ,:class=>"classname" , :id=>"idname") %> Just make the attribute name in HTML as symbols followed by a value as a key value pair align = "left" HTML :align => "left" RAILS -Karthikeyan Railsfactory -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit https://groups.google.com/groups/opt_out.
On Mon, Dec 17, 2012 at 12:55 AM, karthikeyan manivasagam <lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote:> Use the options directly in image tag as how you use in html tag,but > little convertion has to be done for Rails code, it will work > > HTML : <img alt="logo" src="logo.png" align="right" > style="background-color:#288AC6; padding:10px;" class="classname" > id="idname" /> > > RAILS : <%= image_tag(''logo.png'', :alt=>''logo'',:align=>''right'' > ,:style=>''background-color:##288AC6; padding:10px;'' ,:class=>"classname" > , :id=>"idname") %> > > Just make the attribute name in HTML as symbols followed by a value > as a key value pair > > align = "left" HTML > :align => "left" RAILSI just want to point out that you should not be using align, it''s not supported in HTML5 because you can use css (read: float) and I also want to point out that if you are just going to make your ALT the same as your src minus extension you might as well not bother and let the spec fail, I wish the engine were smart enough to detect people gaming the system like that. Your desc should actually be a description or don''t bother, you just take the piss out of the desc attribute and what it''s used for in the current example. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit https://groups.google.com/groups/opt_out.