protected function FileEntity::updateImageFieldDimensionsByEntity in File Entity (fieldable files) 8.2
Update the image dimensions on the given image field on the given entity.
Parameters
\Drupal\Core\Entity\FieldableEntityInterface $entity: The entity to be updated.
string $image_field: The field to be updated.
1 call to FileEntity::updateImageFieldDimensionsByEntity()
- FileEntity::updateImageFieldDimensions in src/
Entity/ FileEntity.php - Updates the image dimensions stored in any image fields for a file.
File
- src/
Entity/ FileEntity.php, line 279
Class
- FileEntity
- Replace for the core file entity class.
Namespace
Drupal\file_entity\EntityCode
protected function updateImageFieldDimensionsByEntity(FieldableEntityInterface $entity, $image_field) {
foreach (array_keys($entity
->getTranslationLanguages()) as $langcode) {
$translation = $entity
->getTranslation($langcode);
foreach ($translation->{$image_field} as $item) {
if ($item->target_id == $this
->id()) {
$item->width = $this
->getMetadata('width');
$item->height = $this
->getMetadata('height');
}
}
}
// Save the updated field column values.
$entity
->save();
}