Question

Iam using same code in my index and show page. but i can't able to resize in show method and my code is

<%= image_tag @language.image_url, size:"100*100" %>
Was it helpful?

Solution 2

You're using an asterix in your size attribute. Did you try it with the x character between the width and height numbers?

<%= image_tag @language.image_url, size:"100x100" %>

As some of the other posters have mentioned here, if you're using paperclip, it might be a better idea to resize and store your resized image via paperclip for performance reasons. But if you want to keep the image resizing in HTML, then try using x instead of *.

OTHER TIPS

you can resize as follows:

<%= image_tag @language.image_url, width: 100, height: 100 %>

Try this one

<%= image_tag(@language.image_url), :style=>'width:100px; height:100px;'%>

But you are using the paperclip gems and it provide styles to create the image with required resoluctions.

Below is the example of code that set can be set with paperclip.

class YourModel < ActiveRecord::Base

  has_attached_file :picture, :styles => { :medium => "117x245>", :thumb => "100x100>" }
  validates_attachment_content_type :picture, :content_type => /\Aimage\/.*\Z/

end
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top