Drupal 7 Creating an Image Style Programatically

Submitted by shiv on Wed, 09/14/2016 - 11:07
Drupal 7 Creating an Image Style programmatically through theme
Insert below code into template.php file
 
<?php 
/** * Implements hook_theme_suggestions_HOOK_alter(). */ 
  $style = image_style_save(array('name' =--> 'Banner'));
  $effect = array(
    'name' => 'image_scale',
    'data' => array(
      'width' => 1140,
      'height' => 450,
      'upscale' => TRUE,
    ),
    'isid' => $style['isid'],
  );
  image_effect_save($effect);
?> 
 
Same code can be put into Module's .install file so after installation of module image style will be created programmatically.

Sample blackbox block

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Maecenas non porta odio, id mattis erat.

Nam sed tincidunt eros. Donec a venenatis odio, vitae commodo sem. Vivamus ullamcorper pellentesque erat, in adipiscing tortor scelerisque sit amet. Nulla pulvinar urna magna. Vivamus a ipsum lorem. Etiam adipiscing pulvinar lorem.