gpml_merge_tag_image_sizes
Description
By default, GP Media Library will use the default image sizes generated by WordPress (thumbnail, medium, medium_large, large). In addition to these four sizes, the first images registered with add_image_size will also be included.
This filter allows you to modify which sizes are generated for the Image Merge Tags and, if desired, include all of your image sizes.
Usage
add_filter( 'gpml_merge_tag_image_sizes', 'my_custom_function' );
Parameters
$sizes array
An array of image sizes to use with GP Media Library.
Examples
Return All Available Image Sizes For Image Merge Tags
If you would like to return all available image sizes, simply return the get_intermediate_image_sizes function in the filter.
<?php
/**
* Gravity Perks // Media Library // Return All Available Image Sizes For Image Merge Tags
* https://gravitywiz.com/documentation/gravity-forms-media-library/
*/
add_filter( 'gpml_merge_tag_image_sizes', function( $sizes ) {
return get_intermediate_image_sizes();
} );
Add A Custom Size
Looking to replace the default sizes and include only sizes that you specify? Simply return an array of image sizes like so:
<?php
/**
* Gravity Perks // Media Library // Add A Custom Size
* https://gravitywiz.com/documentation/gravity-forms-media-library/
*/
add_filter( 'gpml_merge_tag_image_sizes', function( $sizes ) {
return array( 'image_one', 'image_two' );
} );
Add A Size to the List
Need to add an image size to the list of sizes? Simply add the image size to the array of images sizes like this
<?php
/**
* Gravity Perks // Media Library // Add A Size to the List
* https://gravitywiz.com/documentation/gravity-forms-media-library/
*/
add_filter( 'gpml_merge_tag_image_sizes', function( $sizes ) {
$sizes[] = 'image_one';
} );
Source Code
This filter is located in GP_Media_Library::get_image_merge_tags() in class-gp-media-library.php.
Since
This filter is available since GP Media Library 1.0.4.