PHP Class Jetpack_Photon, jetpack

Afficher le fichier Open project: automattic/jetpack Class Usage Examples

Protected Properties

Свойство Type Description
$extensions Allowed extensions must match http://code.trac.wordpress.org/browser/photon/index.php#L31
$image_sizes Don't access this directly. Instead, use self::image_sizes() so it's actually populated with something.

Méthodes publiques

Méthode Description
action_wp_enqueue_scripts ( ) : null Enqueue Photon helper script
filter_image_downsize ( string | boolean $image, integer $attachment_id, string | array $size ) : string | boolean Filter post thumbnail image retrieval, passing images through Photon
filter_open_graph_tags ( array $tags, array $parameters ) : array Pass og:image URLs through Photon
filter_sizes ( array $sizes, array $size ) : array Filters an array of image sizes values, using $content_width instead of image's full size.
filter_srcset_array ( array $sources, $size_array, $image_src, $image_meta ) : array Filters an array of image srcset values, replacing each URL with its Photon equivalent.
filter_the_content ( string $content ) : string Identify images in post content, and if images are local (uploaded to the current site), pass through Photon.
filter_the_galleries ( $galleries )
instance ( ) : object Singleton implementation
parse_dimensions_from_filename ( string $src ) : array Try to determine height and width from strings WP appends to resized image filenames.
parse_images_from_html ( string $content ) : array Match all images and any relevant tags in a block of HTML.

Méthodes protégées

Méthode Description
image_sizes ( ) : array Provide an array of available image sizes and corresponding dimensions.
strip_image_dimensions_maybe ( string $src ) : string Checks if the file exists before it passes the file to photon
validate_image_url ( string $url ) : boolean Ensure image URL is valid for Photon.

Private Methods

Méthode Description
__construct ( ) Silence is golden.
setup ( ) : null Register actions and filters, but only if basic Photon functions are available.

Method Details

action_wp_enqueue_scripts() public méthode

Enqueue Photon helper script
public action_wp_enqueue_scripts ( ) : null
Résultat null

filter_image_downsize() public méthode

Filter post thumbnail image retrieval, passing images through Photon
public filter_image_downsize ( string | boolean $image, integer $attachment_id, string | array $size ) : string | boolean
$image string | boolean
$attachment_id integer
$size string | array
Résultat string | boolean

filter_open_graph_tags() public méthode

Pass og:image URLs through Photon
public filter_open_graph_tags ( array $tags, array $parameters ) : array
$tags array
$parameters array
Résultat array

filter_sizes() public méthode

Filters an array of image sizes values, using $content_width instead of image's full size.
Since: 4.0.4
Since: 4.1.0 Returns early for images not within the_content.
public filter_sizes ( array $sizes, array $size ) : array
$sizes array An array of media query breakpoints.
$size array Width and height of the image
Résultat array An array of media query breakpoints.

filter_srcset_array() public méthode

Filters an array of image srcset values, replacing each URL with its Photon equivalent.
Since: 3.8.0
Since: 4.0.4 Added automatically additional sizes beyond declared image sizes.
public filter_srcset_array ( array $sources, $size_array, $image_src, $image_meta ) : array
$sources array An array of image urls and widths.
Résultat array An array of Photon image urls and widths.

filter_the_content() public static méthode

Identify images in post content, and if images are local (uploaded to the current site), pass through Photon.
public static filter_the_content ( string $content ) : string
$content string
Résultat string

filter_the_galleries() public static méthode

public static filter_the_galleries ( $galleries )

image_sizes() protected static méthode

Similar to get_intermediate_image_sizes() except that it includes image sizes' dimensions, not just their names.
protected static image_sizes ( ) : array
Résultat array

instance() public static méthode

Singleton implementation
public static instance ( ) : object
Résultat object

parse_dimensions_from_filename() public static méthode

Try to determine height and width from strings WP appends to resized image filenames.
public static parse_dimensions_from_filename ( string $src ) : array
$src string The image URL.
Résultat array An array consisting of width and height.
Checks if the file exists before it passes the file to photon
protected static strip_image_dimensions_maybe ( string $src ) : string
$src string The image URL
Résultat string

validate_image_url() protected static méthode

Though Photon functions address some of the URL issues, we should avoid unnecessary processing if we know early on that the image isn't supported.
protected static validate_image_url ( string $url ) : boolean
$url string
Résultat boolean

Property Details

$extensions protected_oe static_oe property

Allowed extensions must match http://code.trac.wordpress.org/browser/photon/index.php#L31
protected static $extensions

$image_sizes protected_oe static_oe property

Don't access this directly. Instead, use self::image_sizes() so it's actually populated with something.
protected static $image_sizes