Commit f0b2fde4 authored by alexpott's avatar alexpott

Issue #3052271 by amateescu, catch, mikelutz, alexpott, xaqrox, jimik42,...

Issue #3052271 by amateescu, catch, mikelutz, alexpott, xaqrox, jimik42, plach, phenaproxima, rfmarcelino, mzvaan: media_library_update_8701() fails during update from 8.6.15 to 8.7.0
parent b9f30c93
......@@ -5,7 +5,6 @@
* Install, update and uninstall functions for the media_library module.
*/
use Drupal\image\Entity\ImageStyle;
use Drupal\media\Entity\MediaType;
use Drupal\views\Entity\View;
......@@ -60,21 +59,8 @@ function media_library_uninstall() {
* Create the 'media_library' image style.
*/
function media_library_update_8701() {
$image_style = ImageStyle::create([
'name' => 'media_library',
'label' => 'Media Library (220x220)',
]);
// Add a scale effect.
$image_style->addImageEffect([
'id' => 'image_scale',
'weight' => 0,
'data' => [
'width' => 220,
'height' => 220,
'upscale' => FALSE,
],
]);
$image_style->save();
// This update function has been moved to
// media_library_post_update_add_media_library_image_style().
}
/**
......@@ -229,6 +215,6 @@ function media_library_update_8702() {
'plugin_id' => 'string',
],
]);
$view->save();
$view->save(TRUE);
}
}
......@@ -7,6 +7,7 @@
use Drupal\Core\Entity\Entity\EntityFormMode;
use Drupal\Core\Entity\Entity\EntityViewMode;
use Drupal\image\Entity\ImageStyle;
use Drupal\media\Entity\MediaType;
use Drupal\views\Views;
......@@ -210,3 +211,32 @@ function media_library_post_update_table_display() {
$view->save();
}
/**
* Create the 'media_library' image style if necessary.
*/
function media_library_post_update_add_media_library_image_style() {
// Bail out early if the image style was already created by
// media_library_update_8701(), or manually by the site owner.
if (ImageStyle::load('media_library')) {
return;
}
$image_style = ImageStyle::create([
'name' => 'media_library',
'label' => 'Media Library (220x220)',
]);
// Add a scale effect.
$image_style->addImageEffect([
'id' => 'image_scale',
'weight' => 0,
'data' => [
'width' => 220,
'height' => 220,
'upscale' => FALSE,
],
]);
$image_style->save();
return t('The %label image style has been created successfully.', ['%label' => 'Media Library (220x220)']);
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment