how to get a paperclip style file_size

Posted on 2009-12-17
Last Modified: 2013-11-13
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.
Question by:lusfernandos
    LVL 10

    Expert Comment

    by:Andrew Doades
    I believe you use something like below..

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

    Open in new window

    LVL 2

    Author Comment

    Hi doades,

     Unfortunately, that didn't work !
    LVL 10

    Expert Comment

    by:Andrew Doades
    Looking at the paperclip website it looks like you need something like this:

    <%= image_tag %>

    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?

    LVL 2

    Author Comment

    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.
    LVL 2

    Accepted Solution

    ok, I got it working.

    should be something like:

        <td><%=h number_to_human_size(File.size( %></td>  

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    How to improve team productivity

    Quip adds documents, spreadsheets, and tasklists to your Slack experience
    - Elevate ideas to Quip docs
    - Share Quip docs in Slack
    - Get notified of changes to your docs
    - Available on iOS/Android/Desktop/Web
    - Online/Offline

    Suggested Solutions

    In Ruby, Call or invoke a API DLL library is easily via Win32API class, win32-api gem or other gems. For general DLL API call, there are quite a few references, some good tips list below:…
    Recently I spent hours debugging an issue in a Rails project where ActiveRecord was causing MySQL errors trying to create a User object of a class at the top level of a Single Table Inheritance model structure.  It turns out `.create` behaves differ…
    Migrating to Microsoft Office 365 is becoming increasingly popular for organizations both large and small. If you have made the leap to Microsoft’s cloud platform, you know that you will need to create a corporate email signature for your Office 365…
    Hi everyone! This is Experts Exchange customer support.  This quick video will show you how to change your primary email address.  If you have any questions, then please Write a Comment below!

    759 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    9 Experts available now in Live!

    Get 1:1 Help Now