• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1626
  • Last Modified:

how to get a paperclip style file_size

Hi I am using paperclip to deal with images files, and I want to show in a list the file size of a style.
My styles are:
    :styles => {:small => "200x200>", :medium => "300x300>", :thumb => "60x60>"}

In a view I am getting the image original size, however I want to show the :medium filesize
Here is how I am showing in the view

    <td><%=h number_to_human_size(photo.photo_file_size)%></td>

I guess that I need to use (:medium) somewhere but I don't know where, or if I really need to use some other function to get the style size, I think the only size paperclip stores is from the original image.
Thanks for your support.
0
lusfernandos
Asked:
lusfernandos
  • 3
  • 2
1 Solution
 
Andrew DoadesCommented:
I believe you use something like below..

Andrew
<td><%=h number_to_human_size(photo.photo_file_size(:medium))%></td>

Open in new window

0
 
lusfernandosAuthor Commented:
Hi doades,

 Unfortunately, that didn't work !
0
 
Andrew DoadesCommented:
Looking at the paperclip website it looks like you need something like this:

<%= image_tag @photo.photo.url(:medium) %>

to show the image in that size, e.g. 300x300

I'm not 100% sure about what you mean by show the filesize, do you mean show the size of the file as in size on disk?

Andrew
0
 
lusfernandosAuthor Commented:
I am able to show the images with all styles.
however  I need to show the filesie from a specific size. The filesize I am currently able to show is for the original image.
0
 
lusfernandosAuthor Commented:
ok, I got it working.

should be something like:

    <td><%=h number_to_human_size(File.size(photo.photo.path(:medium))) %></td>  
0

Featured Post

Vote for the Most Valuable Expert

It’s time to recognize experts that go above and beyond with helpful solutions and engagement on site. Choose from the top experts in the Hall of Fame or on the right rail of your favorite topic page. Look for the blue “Nominate” button on their profile to vote.

  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now