You are here

BlazyInterface.php in Blazy 7

Same filename and directory in other branches
  1. 8.2 src/BlazyInterface.php
  2. 8 src/BlazyInterface.php

Namespace

Drupal\blazy

File

src/BlazyInterface.php
View source
<?php

namespace Drupal\blazy;


/**
 * Defines re-usable services and functions for blazy plugins.
 */
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 = []);

}

Interfaces

Namesort descending Description
BlazyInterface Defines re-usable services and functions for blazy plugins.