Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
A
avif
Manage
Activity
Members
Labels
Plan
Wiki
Custom issue tracker
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Model registry
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
project
avif
Merge requests
!22
Resolve
#3188912
"Incompatibility with webp"
Code
Review changes
Check out branch
Download
Patches
Plain diff
Open
Resolve
#3188912
"Incompatibility with webp"
issue/avif-3188912:3188912-incompatibility-with-webp
into
1.0.x
Overview
0
Commits
2
Pipelines
1
Changes
8
Open
igor mashevskyi
requested to merge
issue/avif-3188912:3188912-incompatibility-with-webp
into
1.0.x
1 year ago
Overview
0
Commits
2
Pipelines
1
Changes
8
Expand
Closes
#3188912
0
0
Merge request reports
Compare
1.0.x
1.0.x (HEAD)
and
latest version
latest version
da5d035d
2 commits,
1 year ago
8 files
+
352
−
32
Side-by-side
Compare changes
Side-by-side
Inline
Show whitespace changes
Show one file at a time
Files
8
Search (e.g. *.vue) (Ctrl+P)
src/PathProcessor/PathProcessorAvifImageStyles.php
0 → 100644
+
62
−
0
Options
<?php
namespace
Drupal\avif\PathProcessor
;
use
Drupal\Core\PathProcessor\InboundPathProcessorInterface
;
use
Drupal\Core\StreamWrapper\StreamWrapperManagerInterface
;
use
Symfony\Component\HttpFoundation\Request
;
/**
* Defines a path processor to rewrite image styles URLs for avif.
*
* @see \Drupal\image\PathProcessor\PathProcessorImageStyles
*/
class
PathProcessorAvifImageStyles
implements
InboundPathProcessorInterface
{
/**
* The stream wrapper manager service.
*
* @var \Drupal\Core\StreamWrapper\StreamWrapperManagerInterface
*/
protected
$streamWrapperManager
;
/**
* Constructs a new PathProcessorAvifImageStyles object.
*
* @param \Drupal\Core\StreamWrapper\StreamWrapperManagerInterface $stream_wrapper_manager
* The stream wrapper manager service.
*/
public
function
__construct
(
StreamWrapperManagerInterface
$stream_wrapper_manager
)
{
$this
->
streamWrapperManager
=
$stream_wrapper_manager
;
}
/**
* {@inheritdoc}
*/
public
function
processInbound
(
$path
,
Request
$request
)
{
$directory_path
=
$this
->
streamWrapperManager
->
getViaScheme
(
'public'
)
->
getDirectoryPath
();
if
(
strpos
(
$path
,
'/avif/'
.
$directory_path
.
'/styles/'
)
===
0
)
{
$path_prefix
=
'/avif/'
.
$directory_path
.
'/styles/'
;
}
else
{
return
$path
;
}
// Strip out path prefix.
$rest
=
preg_replace
(
'|^'
.
preg_quote
(
$path_prefix
,
'|'
)
.
'|'
,
''
,
$path
);
// Get the image style, scheme and path.
if
(
substr_count
(
$rest
,
'/'
)
>=
2
)
{
[
$image_style
,
$scheme
,
$file
]
=
explode
(
'/'
,
$rest
,
3
);
// Set the file as query parameter.
$request
->
query
->
set
(
'file'
,
$file
);
return
$path_prefix
.
$image_style
.
'/'
.
$scheme
;
}
else
{
return
$path
;
}
}
}
Loading