Sha256: 32c7f104e3f3c9b16ca18f41a757d2bf8d004db11527384a07df5f5cbc74571d
Contents?: true
Size: 1.28 KB
Versions: 1
Compression:
Stored size: 1.28 KB
Contents
require "active-fedora" require "active_fedora_finders" class StaticImageAggregator < ::ActiveFedora::Base extend ActiveModel::Callbacks include ::ActiveFedora::Finders include ::ActiveFedora::DatastreamCollections include ::Hydra::ModelMethods include Cul::Scv::Hydra::Models::Common include Cul::Scv::Hydra::Models::Aggregator alias :file_objects :resources CUL_WIDTH = "http://purl.oclc.org/NET/CUL/RESOURCE/STILLIMAGE/BASIC/imageWidth" CUL_LENGTH = "http://purl.oclc.org/NET/CUL/RESOURCE/STILLIMAGE/BASIC/imageLength" def route_as "image" end def index_type_label "PART" end def thumbnail_info candidate = nil max_dim = 251 resources.each do |pid| resource = Resource.find(pid) width = resource.object_relations[CUL_WIDTH].first.to_i length = resource.object_relations[CUL_LENGTH].first.to_i max = (width > length) ? width : length if max_dim > max candidate = resource max_dim = max end end if candidate.nil? return {:url=>image_url("cul_scv_hydra/crystal/file_broken.png"),:mime=>'image/png'} else return {:url=>"#{ActiveFedora.fedora_config[:url]}/objects/#{candidate.pid}/datastreams/CONTENT/content",:mime=>candidate.datastreams['CONENT'].mimeType} end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
cul_scv_hydra-0.11.0 | app/models/static_image_aggregator.rb |