Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
J
jsonapi_image_styles
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
jsonapi_image_styles
Commits
ce31d453
There was an error fetching the commit references. Please try again later.
Commit
ce31d453
authored
3 years ago
by
Leon Kessler
Committed by
Christopher C. Wells
3 years ago
Browse files
Options
Downloads
Patches
Plain Diff
Issue
#3232157
by Leon Kessler: Image styles are generated for other types of file entites
parent
3af64efd
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/Plugin/Field/FieldType/ImageStyleNormalizedFieldItemList.php
+17
-15
17 additions, 15 deletions
...gin/Field/FieldType/ImageStyleNormalizedFieldItemList.php
with
17 additions
and
15 deletions
src/Plugin/Field/FieldType/ImageStyleNormalizedFieldItemList.php
+
17
−
15
View file @
ce31d453
...
...
@@ -21,24 +21,26 @@ protected function computeValue() {
$config
=
\Drupal
::
config
(
'jsonapi_image_styles.settings'
);
$styles
=
[];
$entity
=
$this
->
getEntity
();
$uri
=
(
$entity
instanceof
File
)
?
$entity
->
getFileUri
()
:
FALSE
;
$defined_styles
=
(
$config
->
get
(
'image_styles'
))
?
$config
->
get
(
'image_styles'
)
:
[];
if
(
!
empty
(
array_filter
(
$defined_styles
)))
{
foreach
(
$defined_styles
as
$key
)
{
$styles
[
$key
]
=
ImageStyle
::
load
(
$key
);
$uri
=
(
$entity
instanceof
File
&&
substr
(
$entity
->
getMimeType
(),
0
,
5
)
===
'image'
)
?
$entity
->
getFileUri
()
:
FALSE
;
if
(
$uri
)
{
$defined_styles
=
$config
->
get
(
'image_styles'
)
??
[];
if
(
!
empty
(
array_filter
(
$defined_styles
)))
{
foreach
(
$defined_styles
as
$key
)
{
$styles
[
$key
]
=
ImageStyle
::
load
(
$key
);
}
}
else
{
$styles
=
ImageStyle
::
loadMultiple
();
}
}
else
{
$styles
=
ImageStyle
::
loadMultiple
();
}
$offset
=
0
;
foreach
(
$styles
as
$name
=>
$style
)
{
if
(
$style
instanceof
ImageStyle
)
{
$this
->
list
[]
=
$this
->
createItem
(
$offset
,
[
'url'
=>
[
$name
=>
$style
->
buildUrl
(
$uri
)]]);
$offset
=
0
;
foreach
(
$styles
as
$name
=>
$style
)
{
if
(
$style
instanceof
ImageStyle
)
{
$this
->
list
[]
=
$this
->
createItem
(
$offset
,
[
'url'
=>
[
$name
=>
$style
->
buildUrl
(
$uri
)]]);
}
$offset
++
;
}
$offset
++
;
}
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment