public ImageStyle::flush($path = NULL)
Flushes cached media for this style.
Parameters
string $path: (optional) The original image path or URI. If it's supplied, only this image derivative will be flushed.
Return value
$this
Overrides ImageStyleInterface::flush
File
- core/modules/image/src/Entity/ImageStyle.php, line 243
Class
- ImageStyle
- Defines an image style configuration entity.
Namespace
Drupal\image\Entity
Code
public function flush($path = NULL) { // A specific image path has been provided. Flush only that derivative. if (isset($path)) { $derivative_uri = $this->buildUri($path); if (file_exists($derivative_uri)) { file_unmanaged_delete($derivative_uri); } return $this; } // Delete the style directory in each registered wrapper. $wrappers = $this->getStreamWrapperManager()->getWrappers(StreamWrapperInterface::WRITE_VISIBLE); foreach ($wrappers as $wrapper => $wrapper_data) { if (file_exists($directory = $wrapper . '://styles/' . $this->id())) { file_unmanaged_delete_recursive($directory); } } // Let other modules update as necessary on flush. $module_handler = \Drupal::moduleHandler(); $module_handler->invokeAll('image_style_flush', array($this)); // Clear caches so that formatters may be added for this style. drupal_theme_rebuild(); Cache::invalidateTags($this->getCacheTagsToInvalidate()); return $this; }
Please login to continue.