1 image.module &image_style_add_allowed_uri($style_uri = NULL)

Add an image style URI to the whitelist.

When added to the whitelist, and image style will be generated immediately upon request. This function is usually called by the request that prints out the <img> tag with the image style in the src attribute. The whitelist is then loaded when serving the image if it needs to be generated. Image style requests that are not in the whitelist are throttled in image_style_deliver().

Parameters

$style_uri: The full URI to the image that will be generated. e.g. public://styles/large/example.png.

Return value

array: The list of all images added to the whitelist this request. This list is returned by reference to allow the list to be modified.

See also

image_style_get_allowed_uris()

image_style_remove_allowed_uri()

image_style_save_allowed_uris()

File

core/modules/image/image.module, line 1001
Exposes global functionality for creating image styles.

Code

function &image_style_add_allowed_uri($style_uri = NULL) {
  $added_uris = &backdrop_static('image_style_allowed_uris', array());

  // It's likely that multiple images will be whitelisted during a single
  // request, so we only save this list once at the end of the request.
  if ($style_uri && empty($added_uris)) {
    register_shutdown_function('image_style_save_allowed_uris');
  }

  if ($style_uri) {
    $added_uris[$style_uri] = TRUE;
  }

  return $added_uris;
}