You are here

function media_update_7211 in D7 Media 7.3

Same name and namespace in other branches
  1. 7.4 media.install \media_update_7211()
  2. 7.2 media.install \media_update_7211()

Save a square_thumbnail image style in the database for legacy support if one does not already exist.

1 call to media_update_7211()
media_update_7227 in ./media.install
Make sure that the image style square_thumbnail is created.

File

./media.install, line 963
Install, update and uninstall functions for the Media module.

Code

function media_update_7211() {
  $default_style = array(
    'name' => 'square_thumbnail',
  );

  // Clear the image cache to remove any old image styles that only exist in
  // code.
  cache_clear_all('image_styles', 'cache_image', TRUE);

  // Check if the square_thumbnail image style exists.
  // The style will only exist if the user has customized it, otherwise it would
  // have been removed by clearing the image style cache.
  $existing_style = image_style_load('square_thumbnail');

  // Save a square_thumbnail image style in the database for legacy support.
  // This is only necessary if a square_thumbnail image style doesn't already
  // exist.
  if (empty($existing_style)) {
    $style = image_style_save($default_style);
    $effect = array(
      'name' => 'image_scale_and_crop',
      'data' => array(
        'width' => 100,
        'height' => 100,
        'weight' => 0,
      ),
      'isid' => $style['isid'],
    );
    image_effect_save($effect);
  }
  return t('Saved a square_thumbnail image style in the database for legacy support if one did not already exist.');
}