Filter hook 'wp_image_src_get_dimensions'

in WP Core File wp-includes/media.php at line 1743

View Source

wp_image_src_get_dimensions

Filter Hook
Description
Filters the 'wp_image_src_get_dimensions' value.

Hook Information

File Location wp-includes/media.php View on GitHub
Hook Type Filter
Line Number 1743

Hook Parameters

Type Name Description
array|false $dimensions Array with first element being the width and second element being the height, or false if dimensions could not be determined.
string $image_src The image source file.
array $image_meta The image meta data as returned by 'wp_get_attachment_metadata()'.
int $attachment_id The image attachment ID. Default 0.

Usage Examples

Basic Usage
<?php
// Hook into wp_image_src_get_dimensions
add_filter('wp_image_src_get_dimensions', 'my_custom_filter', 10, 4);

function my_custom_filter($dimensions, $image_src, $image_meta, $attachment_id) {
    // Your custom filtering logic here
    return $dimensions;
}

Source Code Context

wp-includes/media.php:1743 - How this hook is used in WordPress core
<?php
1738  	 * @param string      $image_src     The image source file.
1739  	 * @param array       $image_meta    The image meta data as returned by
1740  	 *                                   'wp_get_attachment_metadata()'.
1741  	 * @param int         $attachment_id The image attachment ID. Default 0.
1742  	 */
1743  	return apply_filters( 'wp_image_src_get_dimensions', $dimensions, $image_src, $image_meta, $attachment_id );
1744  }
1745  
1746  /**
1747   * Adds 'srcset' and 'sizes' attributes to an existing 'img' element.
1748   *

PHP Documentation

<?php
/**
	 * Filters the 'wp_image_src_get_dimensions' value.
	 *
	 * @since 5.7.0
	 *
	 * @param array|false $dimensions    Array with first element being the width
	 *                                   and second element being the height, or
	 *                                   false if dimensions could not be determined.
	 * @param string      $image_src     The image source file.
	 * @param array       $image_meta    The image meta data as returned by
	 *                                   'wp_get_attachment_metadata()'.
	 * @param int         $attachment_id The image attachment ID. Default 0.
	 */
Quick Info
  • Hook Type: Filter
  • Parameters: 4
  • File: wp-includes/media.php
Related Hooks

Related hooks will be displayed here in future updates.