You are here

interface BlazyInterface in Blazy 7

Same name and namespace in other branches
  1. 8.2 src/BlazyInterface.php \Drupal\blazy\BlazyInterface
  2. 8 src/BlazyInterface.php \Drupal\blazy\BlazyInterface

Defines re-usable services and functions for blazy plugins.

Hierarchy

Expanded class hierarchy of BlazyInterface

All classes that implement BlazyInterface

File

src/BlazyInterface.php, line 8

Namespace

Drupal\blazy
View source
interface BlazyInterface {

  /**
   * Transforms dimensions using an image style.
   *
   * @param string $image_style
   *   The image style.
   * @param object $item
   *   The optional image item.
   *
   * @return array
   *   An array containing width and height transformed by the image style.
   */
  public static function transformDimensions($image_style, $item = NULL);

  /**
   * Builds URLs, cache tags, and dimensions for an individual image.
   *
   * Respects a few scenarios:
   * 1. Blazy Filter or unmanaged file with/ without valid URI.
   * 2. Hand-coded image_url with/ without valid URI.
   * 3. Respects first_uri without image_url such as colorbox/zoom-like.
   * 4. File API via field formatters or Views fields/ styles with valid URI.
   * If we have a valid URI, provides the correct image URL.
   * Otherwise leave it as is, likely hotlinking to external/ sister sites.
   * Hence URI validity is not crucial in regards to anything but #4.
   * The image will fail silently at any rate given non-expected URI.
   *
   * @param array $settings
   *   The given settings being modified.
   * @param object $item
   *   The image item.
   */
  public static function urlAndDimensions(array &$settings, $item = NULL);

  /**
   * Returns the sanitized attributes common for user-defined ones.
   *
   * When IMG and IFRAME are allowed for untrusted users, trojan horses are
   * welcome. Hence sanitize attributes relevant for BlazyFilter. The rest
   * should be taken care of by HTML filters after Blazy.
   *
   * @param array $attributes
   *   The given attributes to sanitize.
   *
   * @return array
   *   The sanitized $attributes suitable for UGC, such as Blazy filter.
   */
  public static function sanitize(array $attributes = []);

}

Members

Namesort descending Modifiers Type Description Overrides
BlazyInterface::sanitize public static function Returns the sanitized attributes common for user-defined ones.
BlazyInterface::transformDimensions public static function Transforms dimensions using an image style.
BlazyInterface::urlAndDimensions public static function Builds URLs, cache tags, and dimensions for an individual image.