You are here

function _image_replace_instance_setting in Image Replace 7

Return image replace settings for the given field instance.

Parameters

array $instance: An array defining the field instance.

string $key: (Optional) The key of the setting to return. If $image_style is omitted, an associative array will be returned indexed with the image style name. If $image_style is given, the value of the setting for the given image style is returned.

string $image_style: (Optional) The name of the image style for which to retrieve the settings. If $key is omitted, all settings for the given image style will be returned. If $key is given, only the value for the given setting key is returned.

Return value

any When a setting is defined matching the parameters, the setting value, otherwise NULL.

2 calls to _image_replace_instance_setting()
image_replace_field_attach_presave in ./image_replace.module
Implements hook_field_attach_presave().
image_replace_form_field_ui_field_edit_form_alter in ./image_replace.module
Implements hook_form_FORM_ID_alter().

File

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

Code

function _image_replace_instance_setting(array $instance, $key = NULL, $image_style = NULL) {
  $settings = isset($instance['settings']['image_replace']) ? $instance['settings']['image_replace'] : array();
  $result = $settings;
  if (isset($key) && isset($image_style)) {
    $result = isset($settings[$image_style][$key]) ? $settings[$image_style][$key] : NULL;
  }
  elseif (isset($image_style)) {
    $result = isset($settings[$image_style]) ? $settings[$image_style] : array();
  }
  elseif (isset($key)) {
    $result = array();
    foreach ($settings as $image_style => $values) {
      if (!empty($values[$key])) {
        $result[$image_style] = $values[$key];
      }
    }
  }
  return $result;
}