Gracefully fail out of image handling in ticket PDF
(cherry picked from commit 730d53c8b6)
This commit is contained in:
parent
6c85df603c
commit
4d4ef597dc
1 changed files with 8 additions and 4 deletions
|
|
@ -49,7 +49,11 @@ class TicketPdf < Prawn::Document
|
||||||
if @conference.picture?
|
if @conference.picture?
|
||||||
conference_image = case @conference.picture.ticket.url[0, 4]
|
conference_image = case @conference.picture.ticket.url[0, 4]
|
||||||
when 'http', 'ftp:' # CDNs
|
when 'http', 'ftp:' # CDNs
|
||||||
open(@conference.picture.ticket.url)
|
begin
|
||||||
|
open(@conference.picture.ticket.url)
|
||||||
|
rescue OpenURI::HTTPError
|
||||||
|
nil
|
||||||
|
end
|
||||||
when '/sys' # local storage
|
when '/sys' # local storage
|
||||||
open([
|
open([
|
||||||
Rails.root,
|
Rails.root,
|
||||||
|
|
@ -57,10 +61,10 @@ class TicketPdf < Prawn::Document
|
||||||
@conference.picture.ticket.url
|
@conference.picture.ticket.url
|
||||||
].join)
|
].join)
|
||||||
end
|
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
|
end
|
||||||
|
conference_image ||= open("#{Rails.root}/public/img/osem-logo.png")
|
||||||
|
image conference_image, at: [@mid_horizontal + 30, cursor], fit: [200, 70]
|
||||||
|
|
||||||
move_down 70
|
move_down 70
|
||||||
draw_text @conference.title.to_s, at: [@mid_horizontal + 30, cursor - 30], size: 12
|
draw_text @conference.title.to_s, at: [@mid_horizontal + 30, cursor - 30], size: 12
|
||||||
draw_text @conference.organization.name.to_s, at: [@mid_horizontal + 30, cursor - 50], size: 12
|
draw_text @conference.organization.name.to_s, at: [@mid_horizontal + 30, cursor - 50], size: 12
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue