Filter hook 'attachment_max_dims'

in WP Core File wp-includes/deprecated.php at line 1951

View Source

attachment_max_dims

Filter Hook
Description
Retrieve HTML content of icon attachment image element.

Hook Information

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

Hook Parameters

Type Name Description
int $id Optional. Post ID.
bool $fullsize Optional. Whether to have full size image. Default false.
array $max_dims Optional. Dimensions of image.

Usage Examples

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

function my_custom_filter($id, $fullsize, $max_dims) {
    // Your custom filtering logic here
    return $id;
}

Source Code Context

wp-includes/deprecated.php:1951 - How this hook is used in WordPress core
<?php
1946  		return false;
1947  
1948  	list($src, $src_file) = $src;
1949  
1950  	// Do we need to constrain the image?
1951  	if ( ($max_dims = apply_filters('attachment_max_dims', $max_dims)) && file_exists($src_file) ) {
1952  
1953  		$imagesize = wp_getimagesize($src_file);
1954  
1955  		if (($imagesize[0] > $max_dims[0]) || $imagesize[1] > $max_dims[1] ) {
1956  			$actual_aspect = $imagesize[0] / $imagesize[1];

PHP Documentation

<?php
/**
 * Retrieve HTML content of icon attachment image element.
 *
 * @since 2.0.0
 * @deprecated 2.5.0 Use wp_get_attachment_image()
 * @see wp_get_attachment_image()
 *
 * @param int   $id       Optional. Post ID.
 * @param bool  $fullsize Optional. Whether to have full size image. Default false.
 * @param array $max_dims Optional. Dimensions of image.
 * @return string|false HTML content.
 */
Quick Info
  • Hook Type: Filter
  • Parameters: 3
  • File: wp-includes/deprecated.php
Related Hooks

Related hooks will be displayed here in future updates.