jekyll-aspect-ratio 0.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/lib/jekyll-aspect-ratio.rb +41 -0
- metadata +49 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: '058a9c7412bba98f8aeea49537c2df702f44d8420d10c6a49953ba4557a6dc6f'
|
4
|
+
data.tar.gz: b573af089a4a2e3fd23fbb08d44dcf5b5cd7f56369e7e349af2bef5542f32b58
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: cba3c22da811c376dbfc6b8648889c2f3cd56f85fe12108f53a219455d3d13e97e8982fb383f75f16d2cb4d1b26854404b1ba26ac73fafa824b231ef89b36c97
|
7
|
+
data.tar.gz: 64c586c4d3e58ac7e98da9ef1bd06ac5f2a854eedc78f5e84f421a996184f211d04aea67812483f7e487c6b03415659a01260909f6bd5010d1b5366eb2f57ff4
|
@@ -0,0 +1,41 @@
|
|
1
|
+
require 'jekyll'
|
2
|
+
require 'mini_exiftool'
|
3
|
+
|
4
|
+
class AspectRatio < Liquid::Tag
|
5
|
+
|
6
|
+
def initialize(tagName, input, tokens)
|
7
|
+
super
|
8
|
+
@input = input
|
9
|
+
end
|
10
|
+
|
11
|
+
def render(context)
|
12
|
+
filepath = context[@input]
|
13
|
+
# Strip off the first '/', as that confuses things with relative filepaths
|
14
|
+
if filepath[0] == "/"
|
15
|
+
filepath = filepath[1..-1]
|
16
|
+
end
|
17
|
+
abspath = File.expand_path(filepath)
|
18
|
+
output = 0
|
19
|
+
|
20
|
+
if (File.file?(abspath))
|
21
|
+
mediaObj = MiniExiftool.new abspath
|
22
|
+
height = mediaObj.image_height
|
23
|
+
width = mediaObj.image_width
|
24
|
+
|
25
|
+
# TODO is it always giving me the longer side as width? if so I could pass in a flag for if it's a horizontal or vertical video?
|
26
|
+
if mediaObj.rotation == 90 or mediaObj.rotation == 180
|
27
|
+
temp = height
|
28
|
+
height = width
|
29
|
+
width = temp
|
30
|
+
end
|
31
|
+
|
32
|
+
if height != 0
|
33
|
+
output = width.to_f/height.to_f
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
return output
|
38
|
+
end
|
39
|
+
|
40
|
+
Liquid::Template.register_tag("aspectratio", AspectRatio)
|
41
|
+
end
|
metadata
ADDED
@@ -0,0 +1,49 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: jekyll-aspect-ratio
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Beth Crane
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2020-05-10 00:00:00.000000000 Z
|
12
|
+
dependencies: []
|
13
|
+
description: "Jekyll-Aspect-Ratio enables the use of a custom Liquid tag {% aspectratio
|
14
|
+
filepath %}, to find the aspect ratio of an image or video file. \n\nExample use
|
15
|
+
cases:\n- Specify the flex-grow value of an item so that a series of items of different
|
16
|
+
aspect ratios can fill up one row, all being the same height\n- Sort or separate
|
17
|
+
items by aspect ratio, to display horizontal vs vertical videos together (aspect
|
18
|
+
ratio < 1 is a portrait item, >1 is landscape)\n"
|
19
|
+
email: hello@bethcrane.com
|
20
|
+
executables: []
|
21
|
+
extensions: []
|
22
|
+
extra_rdoc_files: []
|
23
|
+
files:
|
24
|
+
- lib/jekyll-aspect-ratio.rb
|
25
|
+
homepage: https://github.com/abethcrane/jekyll-aspect-ratio
|
26
|
+
licenses:
|
27
|
+
- MIT
|
28
|
+
metadata: {}
|
29
|
+
post_install_message:
|
30
|
+
rdoc_options: []
|
31
|
+
require_paths:
|
32
|
+
- lib
|
33
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
34
|
+
requirements:
|
35
|
+
- - ">="
|
36
|
+
- !ruby/object:Gem::Version
|
37
|
+
version: '0'
|
38
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
39
|
+
requirements:
|
40
|
+
- - ">="
|
41
|
+
- !ruby/object:Gem::Version
|
42
|
+
version: '0'
|
43
|
+
requirements: []
|
44
|
+
rubygems_version: 3.1.2
|
45
|
+
signing_key:
|
46
|
+
specification_version: 4
|
47
|
+
summary: A Jekyll plugin to create a custom Liquid tag that returns the aspect ratio
|
48
|
+
of an image or video
|
49
|
+
test_files: []
|