1 image.module image_style_flood_lock_name()

Check available image style locks to see if any are available.

This function checks the site-wide setting for maximum simultaneous unauthorized image generations. It uses the locking mechanism rather than the flood control system because this is a site-wide limit and locks are released immediately when the image is generated. So rather than limiting the total number of images generated per time period, it limits the total number of simultaneous images.

Return value

string|FALSE: The lock name if a lock could be acquired. FALSE if the maximum number of images is already being generated.


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


function image_style_flood_lock_name() {
  $max_locks = config_get('system.core', 'image_style_flood_limit');
  $max_locks = isset($max_locks) ? $max_locks : 5;
  for ($n = 0; $n < $max_locks; $n++) {
    $lock_name = 'image_style_flood_' . $n;
    if (lock_may_be_available($lock_name) && lock_acquire($lock_name)) {
      return $lock_name;

  // No locks available.
  return FALSE;