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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
|
# File 'app/models/spotlight/featured_image.rb', line 29
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
45
46
47
|
# File 'app/models/spotlight/featured_image.rb', line 45
def file_present?
image.file.present?
end
|
#iiif_url ⇒ Object
16
17
18
19
20
|
# File 'app/models/spotlight/featured_image.rb', line 16
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
25
26
27
|
# File 'app/models/spotlight/featured_image.rb', line 25
def remote_image_url=(url)
super url unless url.starts_with? '/'
end
|