Class: Spotlight::FeaturedImage

Inherits:
ActiveRecord::Base
  • Object
show all
Defined in:
app/models/spotlight/featured_image.rb

Overview

Featured images for browse categories, feature pages, and exhibits

Direct Known Subclasses

ContactImage, ExhibitThumbnail, Masthead

Instance Method Summary collapse

Instance Method Details

#documentObject



28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
# File 'app/models/spotlight/featured_image.rb', line 28

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

Returns:

  • (Boolean)


44
45
46
# File 'app/models/spotlight/featured_image.rb', line 44

def file_present?
  image.file.present?
end

#iiif_urlObject



16
17
18
19
# 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



24
25
26
# File 'app/models/spotlight/featured_image.rb', line 24

def remote_image_url=(url)
  super url unless url.starts_with? '/'
end