Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

How to rewrite helper wicked_pdf_image_tag to work with paperclip images #41

Open
denoww opened this Issue May 12, 2011 · 8 comments

Comments

Projects
None yet
9 participants

denoww commented May 12, 2011

To works with images from paperclip i rewrite this method

def wicked_pdf_image_tag(img, options={})
if img[0].chr == "/" # images from paperclip
new_image = img.slice 1..-1
image_tag "file://#{Rails.root.join('public', new_image)}", options
else
image_tag "file://#{Rails.root.join('public', 'images', img)}", options
end
end

Thanks. That totally works - I needed that!

manfe commented May 18, 2012

Works for me too!

Thanks!

corroded commented Feb 7, 2013

Is there no pull request for this one yet?

Didn't work for me because my image was not in public folder.
So instead of use wicked_pdf_image_tag i use image_tag with the path on HD to the image.
Ex:

image_tag model_with_paperclip.attached_file_name.path(:style)

and the image render properly in pdf.

Hi! Where should I rewrite the method? Inside application_helper.rb?

Collaborator

unixmonkey commented Sep 29, 2014

@bobbyworx

Exactly.

@germanotm thanks for the tip. It took me age to think using image_tag instead of wicked_pdf_image_tag for my images stored on AWS with paperclip.

rdetert commented Feb 8, 2015

I had the same issue using Dragonfly. Got around it by doing this:

=image_tag "file://#{document.image.path}"

instead of the usual:

=image_tag document.image.url

Loading the absolute image.remote_url from AWS S3 did not do the trick either, to my surprise.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment