Class: Spotlight::FeaturedImage
- Inherits:
-
ActiveRecord::Base
- Object
- ActiveRecord::Base
- Spotlight::FeaturedImage
show all
- Defined in:
- app/models/spotlight/featured_image.rb
Overview
Featured images for browse categories, feature pages, and exhibits
Instance Method Summary
collapse
Instance Method Details
#document ⇒ Object
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
|
# File 'app/models/spotlight/featured_image.rb', line 31
def document
return unless document_global_id && source == 'exhibit'
if @document && document_global_id != @document.to_global_id.to_s
@document = nil
end
@document ||= GlobalID::Locator.locate document_global_id
rescue Blacklight::Exceptions::RecordNotFound => e
Rails.logger.info("Exception fetching record by id: #{document_global_id}")
Rails.logger.info(e)
nil
end
|
#file_present? ⇒ Boolean
47
48
49
|
# File 'app/models/spotlight/featured_image.rb', line 47
def file_present?
image.file.present?
end
|
#iiif_url ⇒ Object
18
19
20
21
22
|
# File 'app/models/spotlight/featured_image.rb', line 18
def iiif_url
return unless iiif_service_base.present?
[iiif_service_base, iiif_region || 'full', image_size.join(','), '0', 'default.jpg'].join('/')
end
|
#remote_image_url=(url) ⇒ Object
This is used to fetch images given the URL field in the CSV uploads If the image is local, this step will fail, which is okay since the only consumer is CSV uploads and the URL is intended to be remote
27
28
29
|
# File 'app/models/spotlight/featured_image.rb', line 27
def remote_image_url=(url)
super url unless url.starts_with? '/'
end
|