Reputation: 6957
I have a TestimonialResource
model which has a resource
field type. The backend works okay where I am able to pick a file to upload as a resource
to the testimonial.
However, I am unable to generate a thumbnail of the resource(if it is an image). I know it works with an image
field type and have done it in the past.
I have also looked at the available methods in the Rails console and it does list thumb
as a method.
However, the following does not work in the front-end view.
<%= testimonial_resource.content.thumb('400x400#').url %>
Content is the RefineryCMS resource.
Can someone point me in the right direction?
Upvotes: 1
Views: 84
Reputation: 1773
Dragonfly stores an image once and produces image variations (thumbnails, formats and enhancements) on-the-fly.
So, all related methods are available only to the image model. That means you can't run those methods on everything, but you have a link or local address to the image. So, you can always build a thumb manually:
require "mini_magick"
image = MiniMagick::Image.open("input.jpg")
image.resize "400x400"
image.format "png"
image.write "output.png"
For the existing image object:
image.thumbnail(:geometry => '400x400#c').url
Upvotes: 1