jekyll-imgwh 1.1 → 1.2.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 +4 -4
- data/lib/jekyll-imgwh/version.rb +1 -1
- data/lib/jekyll-imgwh.rb +25 -10
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 97ed49b87d0bbe492af4ed8522310efabdc9746d7704dda82cbacd7b86aa23de
|
4
|
+
data.tar.gz: 3cf0726edda511915644e2c8fff32ef114caa347debf38a39ef20b0a59e2caf4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 46cd039ca46ee40493efde196c88e47970c85f422c7e061af8403119cb946571770e1a84d0239d20c5aa2aee3f003102e6cc2640e7c1c9b22ebacfbd5001ce56
|
7
|
+
data.tar.gz: 5c259abe5bf29223445f2b2a59f151076015847b97ef740f4730ffc64ea6374e4e62e431e046bea936f0d0926e3c46d0290d0f7ed5937ec97bd4c6c35e003596
|
data/lib/jekyll-imgwh/version.rb
CHANGED
data/lib/jekyll-imgwh.rb
CHANGED
@@ -4,6 +4,7 @@ require "cgi"
|
|
4
4
|
require "fastimage"
|
5
5
|
require "jekyll"
|
6
6
|
require "jekyll-imgwh/version"
|
7
|
+
require "uri"
|
7
8
|
|
8
9
|
module Jekyll
|
9
10
|
module Imgwh
|
@@ -35,16 +36,32 @@ module Jekyll
|
|
35
36
|
|
36
37
|
src = Liquid::Template.parse(@src).render(context)
|
37
38
|
debug "src rendered: '#{src}'"
|
38
|
-
img = "<img src=#{
|
39
|
-
|
40
|
-
path = resolve_path(src, context)
|
41
|
-
size = FastImage.size(path)
|
42
|
-
raise LoadError, "#{NAME}: could not get size of image '#{path}'" unless size
|
39
|
+
img = "<img src=#{quoted src}"
|
43
40
|
|
41
|
+
size = image_size(src, context)
|
44
42
|
debug "image size: #{size}"
|
45
|
-
img << " width=#{
|
43
|
+
img << " width=#{quoted size[0]} height=#{quoted size[1]}" << render_rest(context) << ">"
|
44
|
+
end
|
45
|
+
|
46
|
+
private
|
47
|
+
|
48
|
+
def quoted(value)
|
49
|
+
"#{@quote}#{value}#{@quote}"
|
50
|
+
end
|
46
51
|
|
47
|
-
|
52
|
+
def image_size(src, context)
|
53
|
+
uri = URI(src)
|
54
|
+
|
55
|
+
if uri.scheme.nil?
|
56
|
+
src = resolve_path(CGI.unescape(uri.path), context)
|
57
|
+
else
|
58
|
+
allowed_schemes = context.registers[:site].config.dig(NAME, "allowed_schemes") || []
|
59
|
+
unless allowed_schemes.include?(uri.scheme)
|
60
|
+
raise ArgumentError, "#{NAME}: URIs with '#{uri.scheme}' scheme are not allowed"
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
64
|
+
FastImage.size(src) or raise LoadError, "#{NAME}: could not get size of image '#{src}'"
|
48
65
|
end
|
49
66
|
|
50
67
|
def render_rest(context)
|
@@ -64,9 +81,7 @@ module Jekyll
|
|
64
81
|
rest
|
65
82
|
end
|
66
83
|
|
67
|
-
def resolve_path(
|
68
|
-
path = CGI.unescape(src.sub(%r!\?.*!, ""))
|
69
|
-
|
84
|
+
def resolve_path(path, context)
|
70
85
|
local_path = resolve_local_path(path, context)
|
71
86
|
return local_path if File.file?(local_path)
|
72
87
|
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: jekyll-imgwh
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 1.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Mikalai Ananenka
|
8
8
|
bindir: bin
|
9
9
|
cert_chain: []
|
10
|
-
date: 2025-04-
|
10
|
+
date: 2025-04-23 00:00:00.000000000 Z
|
11
11
|
dependencies:
|
12
12
|
- !ruby/object:Gem::Dependency
|
13
13
|
name: fastimage
|