You are here

function image_replace_effect in Image Replace 7

Image effect callback: Change the image if a replacement is available.

1 string reference to 'image_replace_effect'
image_replace_image_effect_info in ./image_replace.module
Implements hook_image_effect_info().

File

./image_replace.module, line 231
Provides an image style effect replacing the whole image with another one.

Code

function image_replace_effect(&$image, $data) {
  $replacement_file = image_replace_get($data['image_style'], $image->source);
  if ($replacement_file) {
    $replacement_image = image_load($replacement_file);
    if ($replacement_image) {
      foreach ($image as $key => $value) {
        unset($image->{$key});
      }
      foreach ($replacement_image as $key => $value) {
        $image->{$key} = $value;
      }
    }
  }
}