Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7861035
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T22:32:15+00:00 2026-06-02T22:32:15+00:00

I have an application where a user chooses a template. On this template the

  • 0

I have an application where a user chooses a template. On this template the user can upload an image.

I use paperclip to upload the images.

Each template has different image sizes.

Is it possible to set an image style => ‘widthxheight’ dynamically in paperclip?

I want this functionality because if the user decides to change template then they don’t have to upload the photo again they just crop the ‘original’.

Thanks for any help.

I will try to clear this up.

A user uploads an image for the header of a page. The style could be called “header” and the dimensions should be the dimensions for that header space, say “400×600”

Now the user views the images they have uploaded in a gallery. They want to select one of the images for their page but this time its for the “sidebar” which has dimensions “300×100”. I don’t want to make them upload the same image again. I want to create a new style called “sidebar” with dimensions “300×100”. I also don’t want to delete the “header” style or resize it.

How can I do this with paperclip?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-02T22:32:18+00:00Added an answer on June 2, 2026 at 10:32 pm

    If I understand you have in mind something like that: Paperclip change size

    Additionally:

    attr_accessor :size
    
    ...
    self.dimensions = self.size.split("x")
    

    Controller:

    def create
      ...
      @file.size = params[:size] # OR Simply include such field in form
      ...
    end
    

    Example:

    Model:

    class File
      has_attached_file :upload
      attr_accessor :size
      before_save :extract_dimensions
      serialize :dimensions
      ...
      def extract_dimensions
        ...
        self.dimensions = self.size.split("x")
      end
    end
    

    Form:

    <form action="some link">
      ...
      <label>Size: </label><select name="file_size">
        <option value="100x200">Large</option>
        ...
      </select>
    </form>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an application where for each object the user can specify his own
I have an application where each user can choose a custom layout. The layouts
I have a web application that translates sentences into English; the user chooses options
I have an application where the user can write up some questions and add
I have a application whereby a user can destroy other users attached to the
I have an application that allows the user to download a csv. This works
I have an application in which end-users can size and position images in a
I have an application requirement where user chooses color & font for title, labels,
I have localized application where user can choose her preferred language in dropdown control.
We have a website that has a common logon page. A user chooses which

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.