Im using the gem Paperclip in order to upload the images of the users to my server. But I having problems with it. I don’t know how to resize the image size after uploading the image.
I’m using CSS to try to change the size but is not working. I think Paperclip is showing the exactly size that it was saved. Could anyone help me?.
Another question is about the location of the pictures that the gem Paperclip is using. When I add a picture with this gem, Where it is saved?.
Paperclip will post process (resize) your images - if all validations are ok - otherwise post processing will not commence.
Paperclip supports an extensible selection of post-processors. When you define a set of styles for an attachment, by default it is expected that those “styles” are actually “thumbnails”. However, you can do much more than just thumbnail images. By defining a subclass of Paperclip::Processor, you can perform any processing you want on the files that are attached.
this image will have two resized copies, a medium and a thumb
which you may show using a helper:
<%= image_tag @user.avatar.url(:medium) %>
location of file:
(from https://github.com/thoughtbot/paperclip - understanding storage): The files that are assigned as attachments are, by default, placed in the directory specified by the :path option to has_attached_file. By default, this location is :rails_root/public/system/:class/:attachment/:id_partition/:style/:filename.
The files are saved in public/system. Read the “Storage” paragraph of the README for a better comprehension
NOTE:
Remember, when using CSS to show different sizes of an image, that the image is downloaded in the original size: if you show an image 200x200 px (using css) but the image is 2000x2000 (1 or 2 MB) you download the full image, which is a very slow solution!
Hi there,
I’ve been problems using this line: “<%= image_tag @user.avatar.url(:medium) %>”
When I use that line, in the browser I just can see text instead of the picture. And RubyMine does not recognize “avatar”. If I use this line the browser shows the picture but I cant resize the picture. **<%= image_tag @user.avatar_file_name %>**Any idea?.
I've been problems using this line: "<%= image_tag @user.avatar.url(:medium) %>"
When I use that line, in the browser I just can see text instead of the picture. And RubyMine does not recognize "avatar". If I use this line the browser shows the picture but I cant resize the picture. <%= image_tag @user.avatar_file_name %>
Any idea?.
Thank you.
Alfredo.
Is your attachment called avatar? Or is it called something else, like picture? In the example code, they are presuming that your attachment is called avatar, and everything proceeds from that point.