module PdfCover::ClassMethods::CarrierWave
Public Instance Methods
pdf_cover_attachment(options = {})
click to toggle source
When called in the context of a CarrierWave::Uploader::Base subclass, this method will add a processor to the currenct attachment or version that generates a JPEG with 95 quality from the first page of the given PDF.
This will not make any validation on the given content type, you must [do it yourself](github.com/carrierwaveuploader/carrierwave#securing-uploads) on your uploader.
@example Adding a version to your uploader:
class WithCarrierwaveUploader < CarrierWave::Uploader::Base include PdfCover storage :file version :image do pdf_cover_attachment end end
# File lib/pdf_cover.rb, line 32 def pdf_cover_attachment(options = {}) process pdf_cover: [options[:quality], options[:resolution]] process enforce_content_type: "image/jpeg" define_method :full_filename do |for_file = model.logo.file| for_file.gsub(/pdf$/i, "jpeg") end end