Skip to content
Snippets Groups Projects
Commit cc44525d authored by Gaus Surahman's avatar Gaus Surahman
Browse files

Issue #3424739 by chanelwheeler: Unable to assign link to image

parent 89c0f921
Branches
Tags
No related merge requests found
Pipeline #115368 passed with warnings
Blazy 8.x-2.0-dev, 2024-03-09
------------------------------
- Issue #3424739 by chanelwheeler: Unable to assign link to image
Blazy 8.x-2.0-dev, 2024-02-01
------------------------------
- Issue #3411047 by heddn: The definition for the sequence declares the type of
......
......@@ -38,7 +38,7 @@ trait TraitDescriptions {
'preload' => $this->t("Preload to optimize the loading of late-discovered resources. Normally large or hero images below the fold. By preloading a resource, you tell the browser to fetch it sooner than the browser would otherwise discover it before Native lazy or lazyloader JavaScript kicks in, or starts its own preload or decoding. The browser caches preloaded resources so they are available immediately when needed. Nothing is loaded or executed at preloading stage. <br>Just a friendly heads up: do not overuse this option, because not everything are critical, <a href=':url'>read more</a>.", [
':url' => 'https://www.drupal.org/node/3262804',
]),
'link' => $this->t('<strong>Supported types</strong>: Link or plain Text containing URL. Link to content: Read more, View Case Study, etc. If an entity, be sure its formatter is linkable strings like ID or Label. <strong>Two behaviors</strong>: <ol><li>If <strong>Media switcher &gt; Image linked by Link field</strong> is selected, it will be gone to serve as a wrapping link of the image, only if its formatter/ output is plain text URL.</li><li>As opposed to <strong>Caption fields</strong> if available, it will be positioned and wrapped with a dedicated class: <strong>@class</strong>.</li></ol>', [
'link' => $this->t('<strong>Supported types</strong>: Link or plain Text containing URL. Link to content: Read more, View Case Study, etc. If an entity, be sure its formatter is linkable strings like ID or Label. <strong>Two behaviors</strong>: <ol><li>If <strong>Media switcher &gt; Image linked by Link field</strong> is available as an option and selected, it will be gone to serve as a wrapping link of the image, only if its formatter/ output is plain text URL.</li><li>As opposed to <strong>Caption fields</strong> if available, it will be positioned and wrapped with a dedicated class: <strong>@class</strong>.</li></ol>', [
'@class' => $namespace == 'blazy' ? 'blazy__caption--link' : $namespace . '__link',
]),
'loading' => $this->t("Decide the `loading` attribute affected by the above fold aka onscreen critical contents aka <a href=':lcp'>LCP</a>. <ul><li>`lazy`, the default: defers loading below fold or offscreen images and iframes until users scroll near them.</li><li>`auto`: browser determines whether or not to lazily load. Only if uncertain about the above fold boundaries given different devices. </li><li>`eager`: loads right away. Similar effect like without `loading`, included for completeness. Good for above fold.</li><li>`defer`: trigger native lazy after the first row is loaded. Will disable global `No JavaScript: lazy` option on this particular field, <a href=':defer'>read more</a>.</li><li>`unlazy`: explicitly removes loading attribute enforced by core. Also removes old `data-[SRC|SRCSET|LAZY]` if `No JavaScript` is disabled. Best for the above fold.</li><li>`slider`, if applicable: will `unlazy` the first visible, and leave the rest lazyloaded. Best for sliders (one visible at a time), not carousels (multiple visible slides at once).</li></ul><b>Note</b>: lazy loading images/ iframes for the above fold is anti-pattern, avoid, <a href=':more'>read more</a>, even <a href=':webdev'>more</a>.", [
......
......@@ -339,11 +339,7 @@ abstract class BlazyFileFormatterBase extends FileFormatterBase {
$type = $field->getType();
$is_image = $type == 'image' || $type == 'svg_image_field';
$_links = ['text', 'string', 'link'];
$links = [];
if (method_exists($field, 'get')) {
$links = $this->getFieldOptions($_links, $field->get('entity_type'));
}
$links = $this->getFieldOptions($_links, $field->getTargetEntityTypeId());
return [
'background' => TRUE,
......@@ -395,9 +391,7 @@ abstract class BlazyFileFormatterBase extends FileFormatterBase {
$captions = 'default';
}
else {
if (method_exists($field, 'get')) {
$captions = $this->getFieldOptions($_texts, $field->get('entity_type'));
}
$captions = $this->getFieldOptions($_texts, $field->getTargetEntityTypeId());
}
return $captions;
}
......@@ -414,7 +408,7 @@ abstract class BlazyFileFormatterBase extends FileFormatterBase {
$field = $this->fieldDefinition;
$target_type = $target_type ?: $this->getFieldSetting('target_type');
$bundles = $this->getAvailableBundles();
$type = method_exists($field, 'get') ? $field->get('entity_type') : NULL;
$type = method_exists($field, 'get') ? $field->get('entity_type') : $field->getTargetEntityTypeId();
if (!$bundles && $type && $service = $this->formatter->service('entity_type.bundle.info')) {
$bundles = $service->getBundleInfo($type);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment