Я действительно не знаю, что еще попробовать.
Я создал тип контента "Предложения" в Drupal 8 с некоторыми полями, заголовком, телом и изображением.поле изображения заполняется путем загрузки или выбора с помощью Entity Browser.(с использованием модуля Media в ядре, с комплектом мультимедиа изображений и т. д.)
Я также создал тип абзаца, используя модуль абзаца, который содержит поле ссылки на сущность для типа контента Предложения.
Чтобы создать тему абзаца, я создал файл параграфа - offer.htm.twig, и я могу увидеть все содержимое предложения, просто используя {{content}}.Теперь я хочу отображать каждое поле отдельно, потому что я хочу добавить свои собственные оболочки HTML и стили CSS.
У меня нет проблем с получением полей заголовка и тела по отдельности, как это:
{{content.field_offer_id [0] ['# node']. Label | striptags}}
{{content.field_offer_id [0] ['# node']. Field_body.value | striptags}}
Где field_offer_id - это имя машины поля абзаца, содержащего предложение
Но получение изображения uri, просто не работает, я думаю, что попробовал все, но, похоже, ничего не работает.Вот то, что я попробовал, и да, некоторые из них могут не иметь смысла, но я просто пытался все из отчаяния:
Это дает мне правильный идентификатор, чтобы я знал, что изображение там:
{{content.field_offer_id [0] ['# node']. Field_offer_image.target_id}}
Все это не возвращает значения
{{file_url (content.field_offer_id [0] ['# node']. field_offer_image.entity.value)}}
{{file_url (content.field_offer_id [0] ['# node']. field_offer_image.entity.fileuri)}}
{{file_url (content.field_offer_id [0] ['# узел']. field_offer_image.entity.uri.value)}}
{{content.field_offer_id[0] ['# узел']. Get_fields ('field_offer_image'). Entity.url ()}}
{{content.field_offer_id [0] ['# node']. Get_fields ('field_offer_image') .entity.uri}}
{{content.field_offer_id [0] ['# узел']. field_offer_image.entity.fileuri.value}}
{{content.field_offer_id [0] ['# узел']. field_offer_image.entity.uri.value |image_style ('offer')}}
{{content.field_offer_id [0] ['# node']. field_offer_image.entity.fileuri | image_style ('offer')}}
Здесьэто дамп kpr {{kpr (content.field_offer_id [0] ['# node']. field_offer_image.0.entity)}}
stdClass Object
([ CLASS ] => Drupal \ media \ Entity \ Media [values: protected] => Массив ([vid] => Массив ([x-default] => 7)
[langcode] => Array
(
[x-default] => en
)
[revision_user] => Array
(
[x-default] =>
)
[revision_created] => Array
(
[x-default] => 1524854915
)
[revision_log_message] => Array
(
[x-default] =>
)
[revision_default] => Array
(
[x-default] => 1
)
[mid] => Array
(
[x-default] => 7
)
[bundle] => Array
(
[x-default] => image
)
[uuid] => Array
(
[x-default] => eb9bb08d-37fa-4900-af14-aa5527f378e4
)
[isDefaultRevision] => Array
(
[x-default] => 1
)
[status] => Array
(
[x-default] => 1
)
[name] => Array
(
[x-default] => Seaworld offer
)
[thumbnail] => Array
(
[x-default] => Array
(
[target_id] => 7
[alt] => Thumbnail
[title] => Seaworld offer
[width] => 567
[height] => 373
)
)
[uid] => Array
(
[x-default] => 1
)
[created] => Array
(
[x-default] => 1524854890
)
[changed] => Array
(
[x-default] => 1524854915
)
[default_langcode] => Array
(
[x-default] => 1
)
[revision_translation_affected] => Array
(
[x-default] => 1
)
[field_image_type] => Array
(
[x-default] => Array
(
[0] => Array
(
[target_id] => 1
)
)
)
[field_media_image] => Array
(
[x-default] => Array
(
[0] => Array
(
[target_id] => 7
[alt] => Seaworld offer
[title] =>
[width] => 567
[height] => 373
)
)
)
)
[fields:protected] => Array
(
)
[fieldDefinitions:protected] =>
[languages:protected] =>
[langcodeKey:protected] => langcode
[defaultLangcodeKey:protected] => default_langcode
[activeLangcode:protected] => x-default
[defaultLangcode:protected] => en
[translations:protected] => Array
(
[x-default] => Array
(
[status] => 1
)
)
[translationInitialize:protected] =>
[newRevision:protected] =>
[isDefaultRevision:protected] => 1
[entityKeys:protected] => Array
(
[bundle] => image
[id] => 7
[revision] => 7
[uuid] => eb9bb08d-37fa-4900-af14-aa5527f378e4
)
[translatableEntityKeys:protected] => Array
(
[label] => Array
(
[x-default] => Seaworld offer
)
[langcode] => Array
(
[x-default] => en
)
[published] => Array
(
[x-default] => 1
)
[default_langcode] => Array
(
[x-default] => 1
)
[revision_translation_affected] => Array
(
[x-default] => 1
)
)
[validated:protected] =>
[validationRequired:protected] =>
[loadedRevisionId:protected] => 7
[revisionTranslationAffectedKey:protected] => revision_translation_affected
[enforceRevisionTranslationAffected:protected] => Array
(
)
[entityTypeId:protected] => media
[enforceIsNew:protected] =>
[typedData:protected] => stdClass Object
(
[__CLASS__] => Drupal\Core\Entity\Plugin\DataType\EntityAdapter
[entity:protected] => stdClass Object
(
[__CLASS__] => Drupal\media\Entity\Media
[values:protected] => Array
(
[vid] => Array
(
[x-default] => 7
)
[langcode] => Array
(
[x-default] => en
)
[revision_user] => Array
(
[x-default] =>
)
[revision_created] => Array
(
[x-default] => 1524854915
)
[revision_log_message] => Array
(
[x-default] =>
)
[revision_default] => Array
(
[x-default] => 1
)
[mid] => Array
(
[x-default] => 7
)
[bundle] => Array
(
[x-default] => image
)
[uuid] => Array
(
[x-default] => eb9bb08d-37fa-4900-af14-aa5527f378e4
)
[isDefaultRevision] => Array
(
[x-default] => 1
)
[status] => Array
(
[x-default] => 1
)
[name] => Array
(
[x-default] => Seaworld offer
)
[thumbnail] => Array
(
[x-default] => Array
(
[target_id] => 7
[alt] => Thumbnail
[title] => Seaworld offer
[width] => 567
[height] => 373
)
)
[uid] => Array
(
[x-default] => 1
)
[created] => Array
(
[x-default] => 1524854890
)
[changed] => Array
(
[x-default] => 1524854915
)
[default_langcode] => Array
(
[x-default] => 1
)
[revision_translation_affected] => Array
(
[x-default] => 1
)
[field_image_type] => Array
(
[x-default] => Array
(
[0] => Array(1)
)
)
[field_media_image] => Array
(
[x-default] => Array
(
[0] => Array(5)
)
)
)
[fields:protected] => Array
(
)
[fieldDefinitions:protected] =>
[languages:protected] =>
[langcodeKey:protected] => langcode
[defaultLangcodeKey:protected] => default_langcode
[activeLangcode:protected] => x-default
[defaultLangcode:protected] => en
[translations:protected] => Array
(
[x-default] => Array
(
[status] => 1
)
)
[translationInitialize:protected] =>
[newRevision:protected] =>
[isDefaultRevision:protected] => 1
[entityKeys:protected] => Array
(
[bundle] => image
[id] => 7
[revision] => 7
[uuid] => eb9bb08d-37fa-4900-af14-aa5527f378e4
)
[translatableEntityKeys:protected] => Array
(
[label] => Array
(
[x-default] => Seaworld offer
)
[langcode] => Array
(
[x-default] => en
)
[published] => Array
(
[x-default] => 1
)
[default_langcode] => Array
(
[x-default] => 1
)
[revision_translation_affected] => Array
(
[x-default] => 1
)
)
[validated:protected] =>
[validationRequired:protected] =>
[loadedRevisionId:protected] => 7
[revisionTranslationAffectedKey:protected] => revision_translation_affected
[enforceRevisionTranslationAffected:protected] => Array
(
)
[entityTypeId:protected] => media
[enforceIsNew:protected] =>
[typedData:protected] => stdClass Object
(
[__CLASS__] => Drupal\Core\Entity\Plugin\DataType\EntityAdapter
[entity:protected] => stdClass Object
(
[__CLASS__] => Drupal\media\Entity\Media
[values:protected] => Array
(
[vid] => Array(1)
[langcode] => Array(1)
[revision_user] => Array(1)
[revision_created] => Array(1)
[revision_log_message] => Array(1)
[revision_default] => Array(1)
[mid] => Array(1)
[bundle] => Array(1)
[uuid] => Array(1)
[isDefaultRevision] => Array(1)
[status] => Array(1)
[name] => Array(1)
[thumbnail] => Array(1)
[uid] => Array(1)
[created] => Array(1)
[changed] => Array(1)
[default_langcode] => Array(1)
[revision_translation_affected] => Array(1)
[field_image_type] => Array(1)
[field_media_image] => Array(1)
)
[fields:protected] => Array
(
)
[fieldDefinitions:protected] =>
[languages:protected] =>
[langcodeKey:protected] => langcode
[defaultLangcodeKey:protected] => default_langcode
[activeLangcode:protected] => x-default
[defaultLangcode:protected] => en
[translations:protected] => Array
(
[x-default] => Array(1)
)
[translationInitialize:protected] =>
[newRevision:protected] =>
[isDefaultRevision:protected] => 1
[entityKeys:protected] => Array
(
[bundle] => image
[id] => 7
[revision] => 7
[uuid] => eb9bb08d-37fa-4900-af14-aa5527f378e4
)
[translatableEntityKeys:protected] => Array
(
[label] => Array(1)
[langcode] => Array(1)
[published] => Array(1)
[default_langcode] => Array(1)
[revision_translation_affected] => Array(1)
)
[validated:protected] =>
[validationRequired:protected] =>
[loadedRevisionId:protected] => 7
[revisionTranslationAffectedKey:protected] => revision_translation_affected
[enforceRevisionTranslationAffected:protected] => Array
(
)
[entityTypeId:protected] => media
[enforceIsNew:protected] =>
[typedData:protected] => stdClass Object
(
[__CLASS__] => Drupal\Core\Entity\Plugin\DataType\EntityAdapter
[entity:protected] => Drupal\media\Entity\Media
[definition:protected] => Drupal\Core\Entity\TypedData\EntityDataDefinition
[name:protected] =>
[parent:protected] =>
[stringTranslation:protected] =>
[typedDataManager:protected] =>
)
[cacheContexts:protected] => Array
(
)
[cacheTags:protected] => Array
(
)
[cacheMaxAge:protected] => -1
[_serviceIds:protected] => Array
(
)
[stringTranslation:protected] =>
)
[definition:protected] => stdClass Object
(
[__CLASS__] => Drupal\Core\Entity\TypedData\EntityDataDefinition
[propertyDefinitions:protected] =>
[definition:protected] => Array
(
[constraints] => Array(2)
)
[typedDataManager:protected] =>
)
[name:protected] =>
[parent:protected] =>
[stringTranslation:protected] =>
[typedDataManager:protected] =>
)
[cacheContexts:protected] => Array
(
)
[cacheTags:protected] => Array
(
)
[cacheMaxAge:protected] => -1
[_serviceIds:protected] => Array
(
)
[stringTranslation:protected] =>
)
[definition:protected] => stdClass Object
(
[__CLASS__] => Drupal\Core\Entity\TypedData\EntityDataDefinition
[propertyDefinitions:protected] =>
[definition:protected] => Array
(
[constraints] => Array
(
[EntityType] => media
[Bundle] => Array
(
[0] => image
)
)
)
[typedDataManager:protected] =>
)
[name:protected] =>
[parent:protected] =>
[stringTranslation:protected] =>
[typedDataManager:protected] =>
)
[cacheContexts:protected] => Array
(
)
[cacheTags:protected] => Array
(
)
[cacheMaxAge:protected] => -1
[_serviceIds:protected] => Array
(
)
[stringTranslation:protected] =>
)