jamesdylangoldstein-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org
2007-Mar-29 19:12 UTC
Some products have 0, 1, 2 or 3 images. How to display- basic eRB question:
So this is the bassic html w/ eRB: <img class="list-image" src="<%= product.pic1_url %>"/> But what if the database has a pic2_url and a pic3_url (some will have 1 picture, some 2, and some 3)? Obviously it shouldn''t display pic2_url and pic3_url if they aren''t there. And what about formatting: I''ve got a 400x400 box set for pictures -- if I have one picture, I''ll have it take up the whole table (supposing all pictures are at least 400x400); if I have two, I''ll have it put the pictures side by side (maybe breaking the table); if I have three, I''ll split the table again. (and no pic_url at all leaves me with a 400px box that I might as well remove.) How do I solve this problem? Of course, I could just point to three "Image unavailable" images. Thanks, JD --~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Ball, Donald A Jr \(Library\)
2007-Mar-29 19:48 UTC
Re: Some products have 0, 1, 2 or 3 images. How to display-basic eRB question:
> So this is the bassic html w/ eRB: > > <img class="list-image" src="<%= product.pic1_url %>"/> > > But what if the database has a pic2_url and a pic3_url (some will have > 1 picture, some 2, and some 3)?<% if product.pic2_url %> <img class="list-image" src="<%= product.pic2_url %>"/> <% end %> perhaps better to model the product pictures as a list instead of hard-coding in the assumption that there will be at most 3 though. then your erb code may become: <% product.pic_urls.each do |url| %> <img class="list-image" src="<%=url%>"/> <% end %> - donald --~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---