Module: ImagesHelper

Defined in:
app/helpers/images_helper.rb

Instance Method Summary collapse

Instance Method Details

#image_autocomplete_tag(image) ⇒ Object



34
35
36
37
38
39
40
41
# File 'app/helpers/images_helper.rb', line 34

def image_autocomplete_tag(image)
  (:figure) do
    (
      image_tag(image.image_file.url(:thumb)) +
      (:caption, "id:#{image.id}", class: ['feedback', 'feedback-primary', 'feedback-thin']) 
    ).html_safe
  end
end

#image_display_url(image) ⇒ Object



53
54
55
56
57
58
59
60
# File 'app/helpers/images_helper.rb', line 53

def image_display_url(image)
  case image.image_file_content_type
  when 'image/tiff'
    "/images/#{image.id}/extract/0/0/#{image.width}/#{image.height}"
  else
    root_url + image.image_file.url[1..-1]
  end
end

!! Rails already provides image_tag, i.e. it is not required here.



5
6
7
8
# File 'app/helpers/images_helper.rb', line 5

def image_link(image, size: :thumb)
  return nil if image.nil?
  link_to(image_tag(image.image_file.url(size)), image)
end

#image_short_url(image, api: true) ⇒ Object

Return a ShortenedUrl to the original file image



16
17
18
19
20
21
22
23
24
25
26
# File 'app/helpers/images_helper.rb', line 16

def image_short_url(image, api: true)
  if !image.kind_of?(::Image) && (Integer(image) rescue false)
    image = ::Image.find(image)
  end

  if api
    short_url( api_v1_image_file_path( image) )
  else
    short_url( image.image_file.url(:original) )
  end
end

#images_recent_objects_partialTrue

Returns indicates a custom partial should be used, see list_helper.rb.

Returns:

  • (True)

    indicates a custom partial should be used, see list_helper.rb



30
31
32
# File 'app/helpers/images_helper.rb', line 30

def images_recent_objects_partial
  true 
end

#images_search_formObject



10
11
12
# File 'app/helpers/images_helper.rb', line 10

def images_search_form
  render('/images/quick_search_form')
end

#thumb_list_tag(object) ⇒ Object



43
44
45
46
47
48
49
50
51
# File 'app/helpers/images_helper.rb', line 43

def thumb_list_tag(object)
  if object.depictions.any?
    object.depictions.collect{|a|
      (:div)  do
        link_to( depiction_tag(a, size: :medium), a.image.image_file.url())
      end
    }.join.html_safe
  end
end