diff --git a/app/pdfs/ticket_pdf.rb b/app/pdfs/ticket_pdf.rb index 9a09f9fe..d21a1e27 100644 --- a/app/pdfs/ticket_pdf.rb +++ b/app/pdfs/ticket_pdf.rb @@ -1,3 +1,5 @@ +require 'open-uri' + class TicketPdf < Prawn::Document def initialize(conference, user, physical_ticket, ticket_layout, file_name) super(page_layout: ticket_layout, page_size: 'A4', filename: file_name) @@ -43,11 +45,17 @@ class TicketPdf < Prawn::Document def draw_second_square move_up 150 if @conference.picture? - if 7 * @conference.picture.image[:width] > 12 * @conference.picture.image[:height] - image "#{Rails.root}/public#{@conference.picture_url}", at: [@mid_horizontal + 30, cursor], width: 120 - else - image "#{Rails.root}/public#{@conference.picture_url}", at: [@mid_horizontal + 30, cursor], height: 70 - end + conference_image = case @conference.picture.ticket.url[0, 4] + when 'http', 'ftp:' # CDNs + open(@conference.picture.ticket.url) + when '/sys' # local storage + open([ + Rails.root, + '/public', + @conference.picture.ticket.url + ].join) + end + image conference_image, at: [@mid_horizontal + 30, cursor] else image "#{Rails.root}/public/img/osem-logo.png", at: [@mid_horizontal + 30, cursor], height: 70 end diff --git a/app/uploaders/picture_uploader.rb b/app/uploaders/picture_uploader.rb index 76cf0708..41bcab7b 100644 --- a/app/uploaders/picture_uploader.rb +++ b/app/uploaders/picture_uploader.rb @@ -52,10 +52,6 @@ class PictureUploader < CarrierWave::Uploader::Base "system/#{object_class_name}/#{mounted_as}/#{model.id}" end - def image - @image ||= MiniMagick::Image.open(file.file) - end - # Create different versions of your uploaded files: version :large do process resize_to_fit: [300, 300] diff --git a/app/views/physical_tickets/show.html.haml b/app/views/physical_tickets/show.html.haml index 40513ae8..7dbc44da 100644 --- a/app/views/physical_tickets/show.html.haml +++ b/app/views/physical_tickets/show.html.haml @@ -31,12 +31,7 @@ = @user.email .col-md-5.col-md-offset-2.box.well - if @conference.picture? - - width = @conference.picture.image[:width] - - height = @conference.picture.image[:height] - - if 10 * width > 15 * height - = image_tag(@conference.picture_url, width: '150') - - else - = image_tag(@conference.picture_url, height: '100') + = image_tag(@conference.picture.ticket.url, class: 'img-responsive') - else = image_tag('/img/osem-logo.png', class: 'img-responsive') %p.text-left