wpgmp_featured_image_size - WP Maps Pro

15000+ live websites are using this google maps wordpress plugin.

wpgmp_featured_image_size

This hook in the WP Maps Pro plugin allows developers to customize the size of the featured image that appears in the infowindow or listing when displaying a post as a location. It is triggered when rendering these images, and the default size is set to ‘medium’.

Usage

Developers can implement this hook in their theme’s functions.php file or in a custom plugin to adjust the featured image size according to their specific requirements. This can be useful for maintaining visual consistency or optimizing page load times by selecting appropriately sized images.

Example 1

This example demonstrates how to change the featured image size to ‘large’.

add_filter('wpgmp_featured_image_size', function($size, $post_id, $map) {
    return 'large';
}, 10, 3);

Example 2

In this case, the featured image size is set conditionally based on the post ID. If the post ID is 123, the size is set to ‘thumbnail’.

add_filter('wpgmp_featured_image_size', function($size, $post_id, $map) {
    if ($post_id == 123) {
        return 'thumbnail';
    }
    return $size;
}, 10, 3);

Example 3

Here, the hook changes the featured image size based on a specific map ID. If the map ID is 456, the size is set to ‘full’.

add_filter('wpgmp_featured_image_size', function($size, $post_id, $map) {
    if ($map->ID == 456) {
        return 'full';
    }
    return $size;
}, 10, 3);

Remember to test changes thoroughly in a staging environment before deploying them live to ensure compatibility and avoid any potential issues with image display.

Install Plugin Now!

Buy this plugin exclusively on CodeCanyon! You’ll get free updates, full support, and if you’re not satisfied, we’ve got you covered with a 30-day money-back guarantee.