Sha256: 7e71a4f1ab6ea7e38c22fad093d1375f2ffc433c162f2854043f21584a5c0ebb

Contents?: true

Size: 1.85 KB

Versions: 4

Compression:

Stored size: 1.85 KB

Contents

require 'paperclip'

if Radiant.config.table_exists?
  if Radiant.config['assets.create_image_thumbnails?']
    # Check that we can run convert
    begin
      output = Paperclip.run('convert', '-version').to_a.first
      Rails.logger.info "Using image thumbnailer: #{output.sub(/Version: /i, '')}"
    rescue Paperclip::CommandNotFoundError
      Radiant.config['assets.create_image_thumbnails?'] = false
      Radiant.config['assets.create_pdf_thumbnails?'] = false
      Rails.logger.warn "ImageMagick 'convert' executable not found: image and pdf thumbnailing disabled."
    rescue Paperclip::PaperclipCommandLineError => e
      Rails.logger.warn "ImageMagick is present but calling 'convert -version' returns an error: #{e}"
    end
  end

  if Radiant.config['assets.create_pdf_thumbnails?']
    # Check that we can run ghostscript
    begin
     output = Paperclip.run('gs', '-v')
     Rails.logger.info "Using PDF thumbnailer: #{output}".to_a.first
    rescue Paperclip::CommandNotFoundError
      Radiant.config['assets.create_pdf_thumbnails?'] = false
      Rails.logger.warn "Ghostscript 'gs' executable not found: pdf thumbnailing disabled."
    rescue Paperclip::PaperclipCommandLineError => e
      Rails.logger.warn "Ghostscript is present but calling 'gs -v' returns an error: #{e}"
    end
  end

  if Radiant.config['assets.create_video_thumbnails?']
    # Check that we can run ffmpeg
    begin
      output = Paperclip.run('ffmpeg', '-version').to_a.first
      Rails.logger.info "Using video frame grabber: #{output}"
    rescue Paperclip::CommandNotFoundError
      Radiant.config['assets.create_video_thumbnails?'] = false
      Rails.logger.warn "FFmpeg executable not found: video thumbnailing disabled."
    rescue Paperclip::PaperclipCommandLineError => e
      Rails.logger.warn "FFmpeg is present but calling 'ffmpeg -L' returns an error: #{e}"
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
radiant-clipped-extension-1.0.3 config/initializers/processors.rb
radiant-clipped-extension-1.0.2 config/initializers/processors.rb
radiant-clipped-extension-1.0.1 config/initializers/processors.rb
radiant-clipped-extension-1.0.0 config/initializers/processors.rb