Drupal 8  8.0.2
ImageStyle Class Reference
Inheritance diagram for ImageStyle:

Public Member Functions

 id ()
 
 postSave (EntityStorageInterface $storage, $update=TRUE)
 
 buildUri ($uri)
 
 buildUrl ($path, $clean_urls=NULL)
 
 flush ($path=NULL)
 
 createDerivative ($original_uri, $derivative_uri)
 
 transformDimensions (array &$dimensions, $uri)
 
 getDerivativeExtension ($extension)
 
 getPathToken ($uri)
 
 deleteImageEffect (ImageEffectInterface $effect)
 
 getEffect ($effect)
 
 getEffects ()
 
 getPluginCollections ()
 
 addImageEffect (array $configuration)
 
 getReplacementID ()
 
 getName ()
 
 setName ($name)
 
- Public Member Functions inherited from ConfigEntityBase
 __construct (array $values, $entity_type)
 
 getOriginalId ()
 
 setOriginalId ($id)
 
 isNew ()
 
 get ($property_name)
 
 set ($property_name, $value)
 
 enable ()
 
 disable ()
 
 setStatus ($status)
 
 status ()
 
 setSyncing ($syncing)
 
 isSyncing ()
 
 setUninstalling ($uninstalling)
 
 isUninstalling ()
 
 createDuplicate ()
 
 preSave (EntityStorageInterface $storage)
 
 calculateDependencies ()
 
 urlInfo ($rel= 'edit-form', array $options=[])
 
 url ($rel= 'edit-form', $options=array())
 
 link ($text=NULL, $rel= 'edit-form', array $options=[])
 
 toUrl ($rel= 'edit-form', array $options=[])
 
 getCacheTagsToInvalidate ()
 
 getDependencies ()
 
 getConfigDependencyName ()
 
 getConfigTarget ()
 
 onDependencyRemoval (array $dependencies)
 
 setThirdPartySetting ($module, $key, $value)
 
 getThirdPartySetting ($module, $key, $default=NULL)
 
 getThirdPartySettings ($module)
 
 unsetThirdPartySetting ($module, $key)
 
 getThirdPartyProviders ()
 
 isInstallable ()
 
 trustData ()
 
 hasTrustedData ()
 
 save ()
 
- Public Member Functions inherited from Entity
 __construct (array $values, $entity_type)
 
 id ()
 
 uuid ()
 
 isNew ()
 
 enforceIsNew ($value=TRUE)
 
 getEntityTypeId ()
 
 bundle ()
 
 label ()
 
 urlInfo ($rel= 'canonical', array $options=[])
 
 toUrl ($rel= 'canonical', array $options=[])
 
 hasLinkTemplate ($rel)
 
 link ($text=NULL, $rel= 'canonical', array $options=[])
 
 toLink ($text=NULL, $rel= 'canonical', array $options=[])
 
 url ($rel= 'canonical', $options=array())
 
 uriRelationships ()
 
 access ($operation, AccountInterface $account=NULL, $return_as_object=FALSE)
 
 language ()
 
 save ()
 
 delete ()
 
 createDuplicate ()
 
 getEntityType ()
 
 preSave (EntityStorageInterface $storage)
 
 postSave (EntityStorageInterface $storage, $update=TRUE)
 
 postCreate (EntityStorageInterface $storage)
 
 referencedEntities ()
 
 getCacheContexts ()
 
 getCacheTagsToInvalidate ()
 
 getCacheTags ()
 
 getCacheMaxAge ()
 
 getOriginalId ()
 
 setOriginalId ($id)
 
 toArray ()
 
 getTypedData ()
 
 __sleep ()
 
 getConfigDependencyKey ()
 
 getConfigDependencyName ()
 
 getConfigTarget ()
 
- Public Member Functions inherited from RefinableCacheableDependencyInterface
 addCacheContexts (array $cache_contexts)
 
 addCacheTags (array $cache_tags)
 
 mergeCacheMaxAge ($max_age)
 
 addCacheableDependency ($other_object)
 

Static Public Member Functions

static postDelete (EntityStorageInterface $storage, array $entities)
 
- Static Public Member Functions inherited from ConfigEntityBase
static sort (ConfigEntityInterface $a, ConfigEntityInterface $b)
 
- Static Public Member Functions inherited from Entity
static preCreate (EntityStorageInterface $storage, array &$values)
 
static preDelete (EntityStorageInterface $storage, array $entities)
 
static postDelete (EntityStorageInterface $storage, array $entities)
 
static postLoad (EntityStorageInterface $storage, array &$entities)
 
static load ($id)
 
static loadMultiple (array $ids=NULL)
 
static create (array $values=array())
 

Protected Member Functions

 getImageEffectPluginManager ()
 
 getPrivateKey ()
 
 getHashSalt ()
 
 addExtension ($path)
 
 fileUriScheme ($uri)
 
 fileUriTarget ($uri)
 
 fileDefaultScheme ()
 
- Protected Member Functions inherited from ConfigEntityBase
 getTypedConfig ()
 
 addDependency ($type, $name)
 
 invalidateTagsOnSave ($update)
 
- Protected Member Functions inherited from Entity
 entityManager ()
 
 entityTypeManager ()
 
 languageManager ()
 
 uuidGenerator ()
 
 linkTemplates ()
 
 urlRouteParameters ($rel)
 
 invalidateTagsOnSave ($update)
 

Static Protected Member Functions

static replaceImageStyle (ImageStyleInterface $style)
 
- Static Protected Member Functions inherited from ConfigEntityBase
static invalidateTagsOnDelete (EntityTypeInterface $entity_type, array $entities)
 
static getConfigManager ()
 
- Static Protected Member Functions inherited from Entity
static invalidateTagsOnDelete (EntityTypeInterface $entity_type, array $entities)
 

Protected Attributes

 $replacementID
 
 $name
 
 $label
 
 $effects = array()
 
 $effectsCollection
 
- Protected Attributes inherited from ConfigEntityBase
 $originalId
 
 $pluginConfigKey
 
 $status = TRUE
 
 $uuid
 
 $langcode = 'en'
 
 $third_party_settings = array()
 
 $_core = []
 
 $trustedData = FALSE
 
- Protected Attributes inherited from Entity
 $entityTypeId
 
 $enforceIsNew
 
 $typedData
 

Detailed Description

Defines an image style configuration entity.

( id = "image_style", label = ("Image style"), handlers = { "form" = { "add" = "Drupal\image\Form\ImageStyleAddForm", "edit" = "Drupal\image\Form\ImageStyleEditForm", "delete" = "Drupal\image\Form\ImageStyleDeleteForm", "flush" = "Drupal\image\Form\ImageStyleFlushForm" }, "list_builder" = "Drupal\image\ImageStyleListBuilder", }, admin_permission = "administer image styles", config_prefix = "style", entity_keys = { "id" = "name", "label" = "label" }, links = { "flush-form" = "/admin/config/media/image-styles/manage/{image_style}/flush", "edit-form" = "/admin/config/media/image-styles/manage/{image_style}", "delete-form" = "/admin/config/media/image-styles/manage/{image_style}/delete", "collection" = "/admin/config/media/image-styles", }, config_export = { "name", "label", "effects", } )

Member Function Documentation

addExtension (   $path)
protected

Adds an extension to a path.

If this image style changes the extension of the derivative, this method adds the new extension to the given path. This way we avoid filename clashes while still allowing us to find the source image.

Parameters
string$pathThe path to add the extension to.
Returns
string The given path if this image style doesn't change its extension, or the path with the added extension if it does.

References ImageStyle\getDerivativeExtension().

Referenced by ImageStyle\buildUri(), and ImageStyle\getPathToken().

Here is the call graph for this function:

Here is the caller graph for this function:

addImageEffect ( array  $configuration)

{Saves an image effect for this style.

Parameters
array$configurationAn array of image effect configuration.
Returns
string The image effect ID.
}

Implements ImageStyleInterface.

References ImageStyle\getEffects(), and Entity\uuidGenerator().

Here is the call graph for this function:

buildUri (   $uri)

{Returns the URI of this image when using this style.The path returned by this function may not exist. The default generation method only creates images when they are requested by a user's browser. Modules may implement this method to decide where to place derivatives.

Parameters
string$uriThe URI or path to the original image.
Returns
string The URI to the image derivative for this style.
}

Implements ImageStyleInterface.

References ImageStyle\addExtension(), ImageStyle\fileDefaultScheme(), ImageStyle\fileUriScheme(), ImageStyle\fileUriTarget(), and ImageStyle\id().

Referenced by ImageStyle\buildUrl(), and ImageStyle\flush().

Here is the call graph for this function:

Here is the caller graph for this function:

buildUrl (   $path,
  $clean_urls = NULL 
)

{Returns the URL of this image derivative for an original image path or URI.

Parameters
string$pathThe path or URI to the original image.
mixed$clean_urls(optional) Whether clean URLs are in use.
Returns
string The absolute URL where a style image can be downloaded, suitable for use in an tag. Requesting the URL will cause the image to be created.
See Also
::deliver()
}

Implements ImageStyleInterface.

References UrlHelper\buildQuery(), ImageStyle\buildUri(), Drupal\config(), file_build_uri(), file_create_url(), file_stream_wrapper_uri_normalize(), file_uri_scheme(), file_uri_target(), Url\fromUri(), ImageStyle\getPathToken(), RequestHelper\isCleanUrl(), Drupal\request(), and Drupal\service().

Here is the call graph for this function:

createDerivative (   $original_uri,
  $derivative_uri 
)

{Creates a new image derivative based on this image style.Generates an image derivative applying all image effects and saving the resulting image.

Parameters
string$original_uriOriginal image file URI.
string$derivative_uriDerivative image file URI.
Returns
bool TRUE if an image derivative was generated, or FALSE if the image derivative could not be generated.
}

Implements ImageStyleInterface.

References drupal_dirname(), FILE_CREATE_DIRECTORY, FILE_MODIFY_PERMISSIONS, file_prepare_directory(), ImageStyle\getEffects(), Drupal\logger(), and Drupal\service().

Here is the call graph for this function:

deleteImageEffect ( ImageEffectInterface  $effect)

{Deletes an image effect from this style.

Parameters
\Drupal\image\ImageEffectInterface$effectThe image effect object.
Returns
$this
}

Implements ImageStyleInterface.

References ImageStyle\getEffects(), ImageEffectInterface\getUuid(), and ConfigEntityBase\save().

Here is the call graph for this function:

fileDefaultScheme ( )
protected

Provides a wrapper for file_default_scheme() to allow unit testing.

Gets the default file stream implementation.

Todo:
: Convert file_default_scheme() into a proper injectable service.
Returns
string 'public', 'private' or any other file scheme defined as the default.

References file_default_scheme().

Referenced by ImageStyle\buildUri().

Here is the call graph for this function:

Here is the caller graph for this function:

fileUriScheme (   $uri)
protected

Provides a wrapper for file_uri_scheme() to allow unit testing.

Returns the scheme of a URI (e.g. a stream).

Parameters
string$uriA stream, referenced as "scheme://target" or "data:target".
See Also
file_uri_target()
Todo:
: Remove when https://www.drupal.org/node/2050759 is in.
Returns
string A string containing the name of the scheme, or FALSE if none. For example, the URI "public://example.txt" would return "public".

References file_uri_scheme().

Referenced by ImageStyle\buildUri().

Here is the call graph for this function:

Here is the caller graph for this function:

fileUriTarget (   $uri)
protected

Provides a wrapper for file_uri_target() to allow unit testing.

Returns the part of a URI after the schema.

Parameters
string$uriA stream, referenced as "scheme://target" or "data:target".
See Also
file_uri_scheme()
Todo:
: Convert file_uri_target() into a proper injectable service.
Returns
string|bool A string containing the target (path), or FALSE if none. For example, the URI "public://sample/test.txt" would return "sample/test.txt".

References file_uri_target().

Referenced by ImageStyle\buildUri().

Here is the call graph for this function:

Here is the caller graph for this function:

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.
Returns
$this
}

Implements ImageStyleInterface.

References ImageStyle\buildUri(), file_unmanaged_delete(), file_unmanaged_delete_recursive(), ConfigEntityBase\getCacheTagsToInvalidate(), Cache\invalidateTags(), Drupal\moduleHandler(), Drupal\service(), and StreamWrapperInterface\WRITE_VISIBLE.

Referenced by ImageStyle\postSave().

Here is the call graph for this function:

Here is the caller graph for this function:

getDerivativeExtension (   $extension)

{Determines the extension of the derivative without generating it.

Parameters
string$extensionThe file extension of the original image.
Returns
string The extension the derivative image will have, given the extension of the original.
}

Implements ImageStyleInterface.

References ImageStyle\getEffects().

Referenced by ImageStyle\addExtension().

Here is the call graph for this function:

Here is the caller graph for this function:

getEffect (   $effect)

{Returns a specific image effect.

Parameters
string$effectThe image effect ID.
Returns
The image effect object.
}

Implements ImageStyleInterface.

References ImageStyle\getEffects().

Here is the call graph for this function:

getEffects ( )

{Returns the image effects for this style.

Returns
|[] The image effect plugin collection.
}

Implements ImageStyleInterface.

References ImageStyle\getImageEffectPluginManager().

Referenced by ImageStyle\addImageEffect(), ImageStyle\createDerivative(), ImageStyle\deleteImageEffect(), ImageStyle\getDerivativeExtension(), ImageStyle\getEffect(), ImageStyle\getPluginCollections(), and ImageStyle\transformDimensions().

Here is the call graph for this function:

Here is the caller graph for this function:

getHashSalt ( )
protected

Gets a salt useful for hardening against SQL injection.

Returns
string A salt based on information in settings.php, not in the database.
Exceptions
\RuntimeException

References Settings\getHashSalt().

Referenced by ImageStyle\getPathToken().

Here is the call graph for this function:

Here is the caller graph for this function:

getImageEffectPluginManager ( )
protected

Returns the image effect plugin manager.

Returns
The image effect plugin manager.

Referenced by ImageStyle\getEffects().

Here is the caller graph for this function:

getName ( )

{Returns the image style.

Returns
string The name of the image style.
}

Implements ImageStyleInterface.

getPathToken (   $uri)

{Generates a token to protect an image style derivative.This prevents unauthorized generation of an image style derivative, which can be costly both in CPU time and disk space.

Parameters
string$uriThe URI of the original image of this style.
Returns
string An eight-character token which can be used to protect image style derivatives against denial-of-service attacks.
}

Implements ImageStyleInterface.

References ImageStyle\addExtension(), ImageStyle\getHashSalt(), ImageStyle\getPrivateKey(), and Crypt\hmacBase64().

Referenced by ImageStyle\buildUrl().

Here is the call graph for this function:

Here is the caller graph for this function:

getPluginCollections ( )

{Gets the plugin collections used by this entity.

Returns
[] An array of plugin collections, keyed by the property name they use to store their configuration.
}

Implements EntityWithPluginCollectionInterface.

References ImageStyle\getEffects().

Here is the call graph for this function:

getPrivateKey ( )
protected

Gets the Drupal private key.

Returns
string The Drupal private key.

Referenced by ImageStyle\getPathToken().

Here is the caller graph for this function:

getReplacementID ( )

{Returns the replacement ID.

Returns
string The name of the image style to use as replacement upon delete.
}

Implements ImageStyleInterface.

id ( )

{Gets the identifier.

Returns
string|int|null The entity identifier, or NULL if the object does not yet have an identifier.
}

Implements EntityInterface.

Referenced by ImageStyle\buildUri().

Here is the caller graph for this function:

static postDelete ( EntityStorageInterface  $storage,
array  $entities 
)
static

{Acts on deleted entities before the delete hook is invoked.Used after the entities are deleted but before invoking the delete hook.

Parameters
\Drupal\Core\Entity\EntityStorageInterface$storageThe entity storage object.
\Drupal\Core\Entity\EntityInterface[]$entities An array of entities.
}

Implements EntityInterface.

postSave ( EntityStorageInterface  $storage,
  $update = TRUE 
)

{Acts on a saved entity before the insert or update hook is invoked.Used after the entity is saved, but before invoking the insert or update hook. Note that in case of translatable content entities this callback is only fired on their current translation. It is up to the developer to iterate over all translations if needed.

Parameters
\Drupal\Core\Entity\EntityStorageInterface$storageThe entity storage object.
bool$updateTRUE if the entity has been updated, or FALSE if it has been inserted.
}

Implements EntityInterface.

References ImageStyle\flush(), and ConfigEntityBase\isSyncing().

Here is the call graph for this function:

static replaceImageStyle ( ImageStyleInterface  $style)
staticprotected

Update field settings if the image style name is changed.

Parameters
\Drupal\image\ImageStyleInterface$styleThe image style.

References EntityInterface\getOriginalId(), and EntityInterface\id().

Here is the call graph for this function:

setName (   $name)

{Sets the name of the image style.

Parameters
string$nameThe name of the image style.
Returns
The class instance this method is called on.
}

Implements ImageStyleInterface.

References ConfigEntityBase\set().

Here is the call graph for this function:

transformDimensions ( array &  $dimensions,
  $uri 
)

{Determines the dimensions of this image style.Stores the dimensions of this image style into $dimensions associative array. Implementations have to provide at least values to next keys:

  • width: Integer with the derivative image width.
  • height: Integer with the derivative image height.
Parameters
array$dimensionsAssociative array passed by reference. Implementations have to store the resulting width and height, in pixels.
string$uriOriginal image file URI. It is passed in to allow effects to optionally use this information to retrieve additional image metadata to determine dimensions of the styled image. ImageStyleInterface::transformDimensions key objective is to calculate styled image dimensions without performing actual image operations, so be aware that performing IO on the URI may lead to decrease in performance.
See Also
ImageEffectInterface::transformDimensions
}

Implements ImageStyleInterface.

References ImageStyle\getEffects().

Here is the call graph for this function:


The documentation for this class was generated from the following file: