Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
M
media_responsive_thumbnail
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
media_responsive_thumbnail
Commits
a583b0a4
Commit
a583b0a4
authored
1 year ago
by
Carlos Busto Capeáns
Committed by
Ivan Vidusenko
1 year ago
Browse files
Options
Downloads
Patches
Plain Diff
Issue
#3030412
by cbccharlie, Fonski: "Link to content" generates only default language URL
parent
6ea41cf9
No related branches found
No related tags found
1 merge request
!3
fix: Link to content generates only default language URL
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/Plugin/Field/FieldFormatter/MediaResponsiveThumbnailFormatter.php
+8
-2
8 additions, 2 deletions
...ield/FieldFormatter/MediaResponsiveThumbnailFormatter.php
with
8 additions
and
2 deletions
src/Plugin/Field/FieldFormatter/MediaResponsiveThumbnailFormatter.php
+
8
−
2
View file @
a583b0a4
...
...
@@ -191,7 +191,7 @@ class MediaResponsiveThumbnailFormatter extends ResponsiveImageFormatter {
->
first
()
:
$file
->
get
(
'thumbnail'
)
->
first
(),
'#item_attributes'
=>
$item_attributes
,
'#responsive_image_style_id'
=>
$responsive_image_style
?
$responsive_image_style
->
id
()
:
''
,
'#url'
=>
$this
->
getMediaThumbnailUrl
(
$file
,
$items
->
getEntity
()),
'#url'
=>
$this
->
getMediaThumbnailUrl
(
$file
,
$items
->
getEntity
()
,
$langcode
),
];
// Add cacheability of each item in the field.
...
...
@@ -223,16 +223,22 @@ class MediaResponsiveThumbnailFormatter extends ResponsiveImageFormatter {
* The media item.
* @param \Drupal\Core\Entity\EntityInterface $entity
* The entity that the field belongs to.
* @param string $langcode
* The language that should be used to render the field. Defaults
* to the current content language.
*
* @return \Drupal\Core\Url|null
* The URL object for the media item or null if we don't want to add
* a link.
*/
protected
function
getMediaThumbnailUrl
(
MediaInterface
$media
,
EntityInterface
$entity
)
{
protected
function
getMediaThumbnailUrl
(
MediaInterface
$media
,
EntityInterface
$entity
,
$langcode
)
{
$url
=
NULL
;
$image_link_setting
=
$this
->
getSetting
(
'image_link'
);
// Check if the formatter involves a link.
if
(
$image_link_setting
==
'content'
)
{
if
(
$langcode
&&
$entity
->
hasTranslation
(
$langcode
))
{
$entity
=
$entity
->
getTranslation
(
$langcode
);
}
if
(
!
$entity
->
isNew
())
{
$url
=
$entity
->
toUrl
();
}
...
...
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