Link to home
Start Free TrialLog in
Avatar of lusfernandos
lusfernandos

asked on

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.
Avatar of Andrew Doades
Andrew Doades
Flag of United Kingdom of Great Britain and Northern Ireland image

I believe you use something like below..

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

Open in new window

Avatar of lusfernandos
lusfernandos

ASKER

Hi doades,

 Unfortunately, that didn't work !
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
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.
ASKER CERTIFIED SOLUTION
Avatar of lusfernandos
lusfernandos

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial