Browse Source

link image as well as text

main
Paul Pound 2 months ago
parent
commit
30b78ce0ca
  1. 3
      src/Plugin/Field/FieldFormatter/OrcidFieldFormatter.php

3
src/Plugin/Field/FieldFormatter/OrcidFieldFormatter.php

@ -42,7 +42,8 @@ class OrcidFieldFormatter extends FormatterBase {
$prefix = 'https://orcid.org/';
// Assumes all field values are just plain text or strings values and not full orcid URLS.
$orcidUrl = $prefix . $item->value;
$imgSrc = '<img class="orcid-id " src="https://orcid.org/sites/default/files/images/orcid_24x24.png">';
$imgSrc = '<a href="'. $orcidUrl .
'"><img class="orcid-id " src="https://orcid.org/sites/default/files/images/orcid_24x24.png"></a>';
$link = Link::fromTextAndUrl($orcidUrl, Url::fromUri($orcidUrl));
$element[$delta] = [$link->toRenderable()];
$element[$delta][0]['#prefix'] = $imgSrc;

Loading…
Cancel
Save