aports/community/ikiwiki/plugin-img-add-webp.patch
2025-04-04 05:27:01 +00:00

34 lines
1.3 KiB
Diff

diff --git a/./IkiWiki/Plugin/img.pm.orig b/./IkiWiki/Plugin/img.pm
index b85824345ed..e4de9e8e3d0 100644
--- a/./IkiWiki/Plugin/img.pm.orig
+++ b/./IkiWiki/Plugin/img.pm
@@ -23,8 +23,8 @@ sub getsetup () {
},
img_allowed_formats => {
type => "string",
- default => [qw(jpeg png gif svg)],
- description => "Image formats to process (jpeg, png, gif, svg, pdf or 'everything' to accept all)",
+ default => [qw(jpeg png gif svg webp)],
+ description => "Image formats to process (jpeg, png, gif, svg, webp, pdf or 'everything' to accept all)",
# ImageMagick has had arbitrary code execution flaws,
# and the whole delegates mechanism is scary from
# that perspective
@@ -36,7 +36,7 @@ sub getsetup () {
sub allowed {
my $format = shift;
my $allowed = $config{img_allowed_formats};
- $allowed = ['jpeg', 'png', 'gif', 'svg'] unless defined $allowed && @$allowed;
+ $allowed = ['jpeg', 'png', 'gif', 'svg', 'webp'] unless defined $allowed && @$allowed;
foreach my $a (@$allowed) {
return 1 if lc($a) eq $format || lc($a) eq 'everything';
@@ -119,6 +119,9 @@ sub preprocess (@) {
elsif ($extension =~ m/^(svg)$/is) {
$format = 'svg';
}
+ elsif ($extension =~ m/^(webp)$/is) {
+ $format = 'webp';
+ }
elsif ($extension =~ m/^(pdf)$/is) {
$format = 'pdf';
$magic = "%PDF-";