You are here

function textimage_text_effect_dimensions in Textimage 7.3

Implements 'textimage_text' image dimensions callback.

1 string reference to 'textimage_text_effect_dimensions'
textimage_image_effect_info in ./textimage.module
Implements hook_image_effect_info().

File

effects/textimage_text.inc, line 821
Implementation of the 'textimage_text' image effect.

Code

function textimage_text_effect_dimensions(array &$dimensions, array $data) {

  // Merge input data with effect defaults.
  $data = drupal_array_merge_deep(_textimage_text_effect_defaults(), $data);

  // Dimensions are potentially affected only if the effect is set to
  // autoextend the background image in case of wrapper overflow.
  if ($data['layout']['overflow_action'] == 'extend') {

    // Dummy image object.
    $image = new stdClass();
    $image->info['width'] = $dimensions['width'];
    $image->info['height'] = $dimensions['height'];
    $image->info['extension'] = 'png';
    $image->info['mime_type'] = 'image/png';
    $image->toolkit = image_get_toolkit();

    // Get the text wrapper resource.
    if (!($wrapper = _textimage_get_text_wrapper($image, $data))) {
      return;
    }

    // The background image new dimensions, after extension.
    $image_new = array(
      'xpos' => 0,
      'ypos' => 0,
      'width' => $image->info['width'],
      'height' => $image->info['height'],
    );

    // Checks if resizing needed.
    list($resized, $offset_wrapper) = _textimage_background_image_resize($image, $wrapper, $data, $image_new);
    if ($resized) {
      $dimensions['width'] = $image_new['width'];
      $dimensions['height'] = $image_new['height'];
    }
  }
}