Is there any tool available for image upload resizing / view based image style rendering?

What is the best method to manage image uploads in Rails? Is there a tool that allows auto-resizing upon image upload based on predefined dimensions? Moreover, is there any tool available that makes it possible to render / regenerate the same originally uploaded image using alternative view based styles, e.g. thumbs, 320x200 or 640x480 etc..? Thanks.

Hi there,

I'd take a look at attache:

regards,

Johnny

Also look at dragonfly. It does "lazy" resizing, so you upload once, then set the size you want later in the view. Images resized in this manner are cached so you only pay the ImageMagick tax once.

Walter

Walter Davis wrote in post #1183498:

Also look at dragonfly. It does "lazy" resizing, so you upload once, then set the size you want later in the view. Images resized in this manner are cached so you only pay the ImageMagick tax once.

Walter

Thanks Walter, I have already installed Dragonfly and it satisfies my needs. Yet, I am still wondering how to define title and/or alt attributes for the uploaded images. Any ideas? Thank you.

You would define those in your view, just as for any other image type. image_tag (ActionView::Helpers::AssetTagHelper) - APIdock

Walter

Walter Davis wrote in post #1183529:

You would define those in your view, just as for any other image type. image_tag (ActionView::Helpers::AssetTagHelper) - APIdock

Walter

I need to specify different alt/title attributes for the different uploaded images. I guess I have to create an image model that specifies an image + title or alt attribute as a string and then nest this model inside another one (e.g. posts or articles etc..). I am still one week into rails, but I believe this is the rails way to do it.

Walter Davis wrote in post #1183529:

You would define those in your view, just as for any other image type. image_tag (ActionView::Helpers::AssetTagHelper) - APIdock

Walter

I need to specify different alt/title attributes for the different uploaded images. I guess I have to create an image model that specifies an image + title or alt attribute as a string and then nest this model inside another one (e.g. posts or articles etc..). I am still one week into rails, but I believe this is the rails way to do it.

The usual way that you do that is to define columns on the ActiveRecord model that has the image attached to it, and then when you use the image_tag helper, you can access those and use them.

image_tag @your_object.file.thumb('200x200#').url, alt: @your_object.alt, title: @your_object.title

If you haven't done so already, please do yourself a favor and invest a few days in working all the way through railstutorial.org. It's free to read and use on line, and it is the best way to learn the basics (and more importantly, the idioms) of Rails. It is an investment that will pay off for years to come.

Walter

Walter Davis wrote in post #1183553:

an image + title or alt attribute as a string and then nest this model inside another one (e.g. posts or articles etc..). I am still one week into rails, but I believe this is the rails way to do it.

The usual way that you do that is to define columns on the ActiveRecord model that has the image attached to it, and then when you use the image_tag helper, you can access those and use them.

image_tag @your_object.file.thumb('200x200#').url, alt: @your_object.alt, title: @your_object.title

If you haven't done so already, please do yourself a favor and invest a few days in working all the way through railstutorial.org. It's free to read and use on line, and it is the best way to learn the basics (and more importantly, the idioms) of Rails. It is an investment that will pay off for years to come.

Walter

Thanks for all the information. Despite that the whole Rails / Ruby system is very new to me, I sense the great power found in here. Things can be achieved fast and accurately with far fewer lines of code than other systems. Moreover, I simply like this framework.