When referencing an image field type from a TWIG file, there is no way to retrieve the image's URI as is possible when referencing image fields when exposed from within other objects types such as nodes. The only values available are target_id, alt, title, width, and height. The entity object is not available.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

mgalgano created an issue. See original summary.

mgalgano’s picture

Issue summary: View changes
mgalgano’s picture

I addressed the issue for my purposes specifically by updating SiteSettingsLoader.php. Please consider this, or a similar possibly more robust, modification in a future release.

private function getValues($entity) {
...
// Exclude fields on the object that are base config.
if (!method_exists(get_class($field_definition), 'isBaseField') || !$field_definition->isBaseField()) {
if ($field_definition->getType() == "image") {
$build[$key] = $field;
} else {
if ($value = $field->getValue()) {
...
}
...
}

scott_euser’s picture

Would the attached patch work for you? As the site settings are heavily cached in one chunk for performance, I would like to avoid storing the entire entity with it.

scott_euser’s picture

Status: Active » Needs review
scott_euser’s picture

Status: Needs review » Fixed

This has been added on the dev branch.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.