Customizing with PHP
This guide applies to:
- Basic
- Professional
In this guide
Introduction
In this nifty guide, we’ll go over customizing with PHP snippets that will allow you to tailor your interactive images more to your liking.
Here is a handy guide on adding PHP filters.
PHP to Change the Thumbnail Image Size
The detail images for hotspots utilize the Thumbnail size, or if you’re using the Tooltip or Lightbox layout, they use the Medium size. To use a larger or smaller version of the detail picture, you can use the following PHP snippet.
Start by using either the Headers & Footer or Code Snippets plugin to add in this snippet of PHP:
add_filter( 'da_detail_image_size', 'my_da_detail_image_size', 10, 4 );
function my_da_detail_image_size( $size, $hotspot, $img_post, $settings )
{ return 'full'; }
And, you can return one of the following image sizes:
- thumb: Thumbnail size (150 x 150 pixels)
- medium: Medium size (maximum 300 x 300 pixels)
- large: Large size (maximum 1024 x 1024 pixels)
- full: Full size (the original size of the uploaded image)

Customizing with PHP to Change H2s to H3s
While we don’t have a direct way to change the H2 headers to H3, we do have a PHP snippet we can offer to achieve this.
add_filter( 'drawattention_hotspot_title', 'drawattention_change_hotspot_heading_tags' );
function drawattention_change_hotspot_heading_tags( $title ) {
return str_replace( 'h2', 'h3', $title ); }
Before:

After:

Disable WP Image Scaling
WordPress issued a 2560px image threshold several years ago, meaning any image larger than this will be automatically resized.
But the good news is that with the following filter, you can disable this threshold. After adding the filter, you should be able to upload images of any size without automatic scaling.
// Disable the WP 5.0.3 Big Image Enhancements Threshold feature:
add_filter( 'big_image_size_threshold', '__return_false' );
Display Coordinates Field
While we don’t have an easy way to duplicate hotspots at the moment, we do have a filter we can offer that will enable the coordinates field in the hotspot editor. This filter will let you collect the coordinates from a hotspot and paste them into a new hotspot. Follow the instructions below to utilize this workaround:
- Add the filter from below to the functions.php file in your theme. This will then enable the coordinates field.
- Create your first hotspot.
- Collect the coordinates from the first hotspot.
- Create a new hotspot and draw it out.
- Enter the coordinates from step 3 into the new second hotspot.
- Repeat as necessary.
add_action('admin_head', 'DA_enable_coordinates');
function DA_enable_coordinates() {
echo '<style>
input[name$="[coordinates]"] {
display: inline-block !important;
}
</style>';
}"
Load a Minified JavaScript File
If PageSpeed Insights, SEMrush, or a similar tool flags Draw Attention’s public.js file as unminified JavaScript, you can have Draw Attention load a minified copy, public.min.js, instead.
This is off by default. To turn it on, add the following filter to your site. Our Adding Custom Code guide covers a few different ways to do that.
add_filter( 'da_load_minified_js', '__return_true' );
Make sure you’re using the latest version of Draw Attention. If you don’t add the filter, your site keeps loading public.js just as before.
To check that it’s working, first clear your caches, including any caching plugin, server cache (like Varnish), or CDN (like Cloudflare). Then open a page with your interactive image, view the page source, and search for public.min.js.
A couple of things to keep in mind:
- If
SCRIPT_DEBUGis turned on in your wp-config.php file, Draw Attention automatically loads the regularpublic.jsinstead, which is easier to read while you’re debugging. - If you defer Draw Attention’s scripts by file path in a caching or optimization plugin (see Hotspot Content Loads on Page), use
/wp-content/plugins/draw-attention-pro/public/assets/js/public.min.jsin place of thepublic.jspath once the filter is on.