jekyll-aspect-ratio 0.0.0 → 0.0.1
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 +4 -4
- data/lib/jekyll-aspect-ratio.rb +21 -8
- metadata +8 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: fd37b32b0b923b0c43e4fdc08a9496743d449898162d6c763c24268f3e720e01
|
4
|
+
data.tar.gz: 42fae0e5c906dfe525a6710a926fee8b9f751df7cd8e86a8636902aa23c42174
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 03d2c8c683e19481c6a2238eae8c92ffbde451477b1f2ecc670c47f25d3820d2e324dca6bd35f23c7f42eb6e05641661b8435e5d35adb66f7e554d247858c8b2
|
7
|
+
data.tar.gz: ad954441f040a353146e6b6e6d1d578c1e8d34992f3b09b813b1ecfe52b1d01de91f0f16393aae9786a0d66d298a15a5312744dcc3c4423d5642642edc22dcfe
|
data/lib/jekyll-aspect-ratio.rb
CHANGED
@@ -3,34 +3,47 @@ require 'mini_exiftool'
|
|
3
3
|
|
4
4
|
class AspectRatio < Liquid::Tag
|
5
5
|
|
6
|
-
def initialize(tagName,
|
6
|
+
def initialize(tagName, content, tokens)
|
7
7
|
super
|
8
|
-
@input =
|
8
|
+
@input = content
|
9
9
|
end
|
10
10
|
|
11
11
|
def render(context)
|
12
|
-
|
13
|
-
#
|
12
|
+
# If this is a parameter name (from {% assign x = "path" %})
|
13
|
+
# then we need to pass that in as a key to context to get its value
|
14
|
+
if context.key?(@input)
|
15
|
+
filepath = context[@input]
|
16
|
+
else
|
17
|
+
filepath = @input
|
18
|
+
end
|
19
|
+
|
20
|
+
# Strip leading spaces and quotes
|
21
|
+
filepath = filepath.strip.tr('"', '').tr('\'', '')
|
22
|
+
|
23
|
+
# Strip off the first '/', if there is one
|
24
|
+
# as that confuses things with relative filepaths
|
14
25
|
if filepath[0] == "/"
|
15
26
|
filepath = filepath[1..-1]
|
16
27
|
end
|
28
|
+
|
29
|
+
# MiniExfitool doesn't like relative paths
|
17
30
|
abspath = File.expand_path(filepath)
|
18
|
-
output = 0
|
19
31
|
|
20
32
|
if (File.file?(abspath))
|
21
33
|
mediaObj = MiniExiftool.new abspath
|
22
34
|
height = mediaObj.image_height
|
23
35
|
width = mediaObj.image_width
|
24
36
|
|
25
|
-
#
|
26
|
-
if mediaObj.rotation == 90 or mediaObj.rotation ==
|
37
|
+
# If the video is rotated, we need to swap width and height
|
38
|
+
if mediaObj.rotation == 90 or mediaObj.rotation == 270
|
27
39
|
temp = height
|
28
40
|
height = width
|
29
41
|
width = temp
|
30
42
|
end
|
31
43
|
|
44
|
+
# Avoid division by zero errors
|
32
45
|
if height != 0
|
33
|
-
output = width.to_f/height.to_f
|
46
|
+
output = (width.to_f/height.to_f).truncate(2)
|
34
47
|
end
|
35
48
|
end
|
36
49
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: jekyll-aspect-ratio
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Beth Crane
|
@@ -10,12 +10,13 @@ bindir: bin
|
|
10
10
|
cert_chain: []
|
11
11
|
date: 2020-05-10 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
|
-
description:
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
13
|
+
description: 'This plugin enables the use of a custom Liquid tag {% aspectratio filepath
|
14
|
+
%}, to find the aspect ratio of an image or video file. This can be used for e.g.
|
15
|
+
specifying the flex-grow value of an item to display items of different aspect ratios
|
16
|
+
on one line at the same height, or to separate out horizontal or vertical videos
|
17
|
+
(aspect ratio > or < than 1).
|
18
|
+
|
19
|
+
'
|
19
20
|
email: hello@bethcrane.com
|
20
21
|
executables: []
|
21
22
|
extensions: []
|