Skip to content

Commit

Permalink
Merge pull request #780 from City-of-Helsinki/UHF-10555
Browse files Browse the repository at this point in the history
UHF-10555: Deprecated image style cleanup
  • Loading branch information
teroelonen authored Dec 5, 2024
2 parents c1df24c + 7e849f1 commit f0844a0
Show file tree
Hide file tree
Showing 7 changed files with 34 additions and 282 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ dependencies:
- field.field.node.news_item.field_news_neighbourhoods
- field.field.node.news_item.field_radioactivity
- field.field.node.news_item.field_short_title
- image.style.3_2_m
- node.type.news_item
module:
- media
Expand Down
28 changes: 27 additions & 1 deletion public/modules/custom/helfi_etusivu/helfi_etusivu.install
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ function helfi_etusivu_install() : void {
// Never override image style settings.
if ($consumer->get('image_styles')->isEmpty()) {
$consumer->set('image_styles', [
'original_l',
'orig_1264w_free',
])
->save();
}
Expand Down Expand Up @@ -288,3 +288,29 @@ function helfi_etusivu_update_9012(): void {
PathAlias::create($path)->save();
}
}

/**
* UHF-10555: Update the deprecated consumer image style.
*/
function helfi_etusivu_update_9013(): void {
/** @var \Drupal\Core\Extension\ModuleHandler $moduleHandler */
$moduleHandler = \Drupal::service('module_handler');

if ($moduleHandler->moduleExists('consumer_image_styles')) {
$storage = \Drupal::entityTypeManager()->getStorage('consumer');

/** @var \Drupal\consumers\Entity\Consumer $consumer */
foreach ($storage->loadMultiple() as $consumer) {
if (!$consumer->get('third_party')->value) {
continue;
}

if (!$consumer->hasField('image_styles')) {
continue;
}

// Update the consumer image styles.
$consumer->set('image_styles', ['orig_1264w_free'])->save();
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ public function viewElements(FieldItemListInterface $items, $langcode) : array {
$item->entity instanceof MediaInterface &&
$item->entity->hasField('field_media_image')
) {
$image_style = $storage->load('og_image');
$image_style = $storage->load('1.9_1200w_630h');
// @phpstan-ignore-next-line
$image_entity = $item->entity->field_media_image;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ dependencies:
- field.field.node.news_item.field_news_neighbourhoods
- field.field.node.news_item.field_radioactivity
- field.field.node.news_item.field_short_title
- image.style.3_2_m
- node.type.news_item
module:
- media
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ dependencies:
- field.field.node.news_article.field_news_neighbourhoods
- field.field.node.news_article.field_radioactivity
- field.field.node.news_article.field_short_title
- image.style.3_2_m
- node.type.news_article
module:
- media
Expand Down
Loading

0 comments on commit f0844a0

Please sign in to comment.