Skip to content
New issue

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

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

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
Open

Comments

@denoww
Copy link

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
@davidray
Copy link

Thanks. That totally works - I needed that!

@manfe
Copy link

manfe commented May 18, 2012

Works for me too!

Thanks!

@corroded
Copy link

corroded commented Feb 7, 2013

Is there no pull request for this one yet?

@germanotm
Copy link

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.

@bobbyworx
Copy link

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

@unixmonkey
Copy link
Collaborator

@bobbyworx

Exactly.

@alain-andre
Copy link

@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
Copy link

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
Projects
None yet
Development

No branches or pull requests

9 participants