Module: Jekyll::PostImage
- Extended by:
- T::Sig
- Defined in:
- lib/post_image.rb
Constant Summary collapse
- JEKYLL_ROOT =
T.let(Jekyll.configuration.source({}), String)
Instance Method Summary collapse
- #post_has_image(post) ⇒ Object
- #post_image(post) ⇒ Object
- #show_flickr_gallery(post) ⇒ Object
- #show_post_gallery(post) ⇒ Object
Instance Method Details
#post_has_image(post) ⇒ Object
49 50 51 52 53 54 |
# File 'lib/post_image.rb', line 49 def post_has_image(post) post_image = post_image(post) !!post_image && file_exists?(post_image) rescue KeyError false end |
#post_image(post) ⇒ Object
34 35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/post_image.rb', line 34 def post_image(post) item_id = post.fetch('relative_path') Jekyll.logger.info('Post Image:', "Retrieving post image for #{item_id}") image = post.fetch('image') { flickr_primary_photo(post) } image = nil unless image && file_exists?(image) if image.nil? && item_id.start_with?('_posts') Jekyll.logger.warn('Post Image:', "Missing post image for #{item_id}") end image end |
#show_flickr_gallery(post) ⇒ Object
57 58 59 60 |
# File 'lib/post_image.rb', line 57 def show_flickr_gallery(post) post.key?('flickr_photoset_id') && !post.fetch('hide_flickr_gallery', false) && !post.fetch('hide_post_gallery', false) end |
#show_post_gallery(post) ⇒ Object
63 64 65 |
# File 'lib/post_image.rb', line 63 def show_post_gallery(post) !post.fetch('hide_post_gallery', false) end |