Skip to content
Snippets Groups Projects
Commit a42b6979 authored by Igor Biki's avatar Igor Biki
Browse files

Merge branch 'feature/ISTWCMS-5206-ibiki-media' into '1.0.x'

ISTWCMS-5206: Using media to get the image.

See merge request !183
parents 7d51bc60 68bda45c
No related branches found
No related tags found
1 merge request!183ISTWCMS-5206: Using media to get the image.
...@@ -107,19 +107,11 @@ function uw_cfg_common_entity_presave(EntityInterface $entity) { ...@@ -107,19 +107,11 @@ function uw_cfg_common_entity_presave(EntityInterface $entity) {
// images will not work. // images will not work.
if ($entity->getEntityTypeId() == 'node') { if ($entity->getEntityTypeId() == 'node') {
// If there is a hero image, continue to process. // If there is a hero image (media), continue to process.
if ($image = $entity->field_uw_hero_image) { if ($media = $entity->field_uw_hero_image->entity) {
// Get the value of the image field. // Hero media exists, get file entity from media.
$image = $entity->field_uw_hero_image->getValue(); if ($file = $media->field_media_image->entity) {
// Ensure that there actually is an image to process.
if ($image) {
// Load the file from the hero image.
$file = \Drupal::entityTypeManager()
->getStorage('file')
->load($image[0]['target_id']);
// Load the image styles that are needed for the hero. // Load the image styles that are needed for the hero.
$uw_styles = \Drupal::service('uw_cfg_common.uw_service')->uwGetResponsiveImageStyles(); $uw_styles = \Drupal::service('uw_cfg_common.uw_service')->uwGetResponsiveImageStyles();
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment