Optimole icon
Performance & Caching

Optimole hooks reference

  • By Optimole
  • v4.2.20 New
  • Updated

Optimole 4.2.20 has 18 actions and 62 filters, read directly from its source code on Nov 17, 2026. The list updates automatically when a new version is released.

How to use these hooks

Actions let you run your own code at a specific moment. Filters let you change a value before the plugin uses it. Put your code in a child theme's functions.php or a code-snippets plugin, never in the plugin's own files, because updates overwrite them.

functions.phpyour child theme
// Run your own code when Optimole fires an action
add_action( 'optml_clear_cache', function( $current_url ) {
	// Your code runs here.
}, 10, 1 );

// Change a value Optimole is about to use
add_filter( 'themeisle_sdk_current_date', function( $datetime ) {
	// Change $datetime here.
	return $datetime;
}, 10, 1 );

Parts of a name in {braces} are filled in at runtime (for example a post type or field ID). Choose Example on any hook for a ready-to-edit snippet.

All hooks

  • inc/rest.php line 1102 · used in 2 places
    /**
     * Clear cache when storing profile data.
     */
    do_action( 'optml_clear_cache', $current_url );
  • inc/admin.php line 1680 · used in 2 places
    /**
     * The current date.
     */
    apply_filters( 'themeisle_sdk_current_date', new \DateTime( 'now' ) );
  • inc/media_rename/attachment_rename.php line 133
    /**
     * Action triggered after the attachment file is renamed.
     */
    do_action( 'optml_after_attachment_url_replace', $this->attachment_id, $old_url, $new_url );
  • inc/manager.php line 972
    /**
     * Filters whether the page is captured and processed at shutdown, outside of
     * PHP's display-handler context, instead of inside the output-buffer handler.
     */
    apply_filters( 'optml_capture_at_shutdown', false );
  • inc/manager.php line 1128
    /**
     * Filters the captured page HTML before Optimole processes it.
     */
    apply_filters( 'optml_captured_page_html', $html );
  • inc/tag_replacer.php line 898
    /**
     * Filters whether Optimole leaves an image's existing sizes attribute
     * unchanged.
     */
    apply_filters( 'optml_keep_existing_sizes', $keep, $tag );
  • inc/v2/PageProfiler/Profile.php line 128
    /**
     * Filter the page profile ID. This can be altered to change to logic
     * differently, i.e generate the id based on the url or query args or other
     * parameters.
     */
    apply_filters( 'optml_page_profile_id', self::get_default_id( $content ), $content );
  • inc/v2/PageProfiler/Profile.php line 98
    /**
     * Filter the storage class. Allows to change the storage class to a different
     * one, i.e a database storage class/file storage class etc.
     */
    apply_filters( 'optml_page_profiler_storage', wp_using_ext_object_cache() ? Storage\ObjectCache::class : Storage\Transients::class );
  • inc/manager.php line 500
    /**
     * Filters whether the temporary `Cache-Control: max-age=300` header is sent
     * while page profiling is pending for the current page.
     */
    apply_filters( 'optml_send_temporary_cache_header', $send );
  • inc/settings.php line 497
    /**
     * Fires when Optimole settings are updated.
     */
    do_action( 'optml_settings_updated' );
  • inc/admin.php line 1706
    /**
     * The black friday sale period flag.
     */
    apply_filters( 'themeisle_sdk_is_black_friday_sale', false );
  • optml_log

    action
    inc/lazyload_replacer.php line 432 · used in 108 places
    do_action( 'optml_log', 'can_lazyload_for: ' . $url . ' ' . $tag );
  • inc/compatibilities/jetpack.php line 48 · used in 10 places
    apply_filters( 'optml_content_url', $value->featured_image );
  • inc/media_offload.php line 1329 · used in 5 places
    apply_filters( 'optml_default_crop', [] );
  • inc/media_offload.php line 760 · used in 5 places
    apply_filters( 'optml_offload_duplicated_images', [], $content_id );
  • inc/compatibilities/facetwp.php line 37 · used in 4 places
    do_action( 'optml_replacer_setup' );
  • inc/compatibilities/cache_enabler.php line 32 · used in 2 places
    do_action( 'cache_enabler_clear_site_cache' );
  • inc/traits/dam_offload_utils.php line 41 · used in 2 places
    apply_filters( 'optml_ensure_source_attachment_id', $id );
  • inc/manager.php line 309 · used in 2 places
    apply_filters( 'optml_force_replacement', false );
  • inc/rest.php line 786 · used in 2 places
    apply_filters( 'optml_register_conflicts', [] );
  • inc/compatibilities/spc.php line 47 · used in 2 places
    do_action( 'swcfpc_purge_cache', [ $location ] );
  • inc/admin.php line 1455 · used in 2 places
    do_action( 'themeisle_internal_page', OPTML_PRODUCT_SLUG, 'dashboard' );
  • inc/compatibilities/breeze.php line 48
    do_action( 'breeze_clear_all_cache' );
  • inc/compatibilities/cache_enabler.php line 51
    do_action( 'cache_enabler_clear_page_cache_by_url', $location );
  • inc/compatibilities/litespeed_cache.php line 52
    do_action( 'litespeed_purge_url', $location );
  • inc/media_offload.php line 2046
    apply_filters( 'optimole_offload_batch', 20 );
  • inc/manager.php line 623
    apply_filters( 'optml_additional_html_classes', [] );
  • inc/manager.php line 447
    do_action( 'optml_after_setup' );
  • inc/url_replacer.php line 286
    apply_filters( 'optml_apply_watermark_for', true, $url );
  • inc/media_rename/attachment_rename.php line 139
    do_action( 'optml_attachment_renamed', $this->attachment_id );
  • inc/media_rename/attachment_replace.php line 116
    do_action( 'optml_attachment_replaced', $this->attachment_id );
  • inc/conflicts/conflicting_plugins.php line 77
    apply_filters( 'optml_conflicting_active_plugins', $conflicting_plugins );
  • inc/conflicts/conflicting_plugins.php line 61
    apply_filters( 'optml_conflicting_defined_plugins', $plugins );
  • inc/manager.php line 664
    apply_filters( 'optml_content_images_tags', $content, $images );
  • inc/media_offload.php line 700
    apply_filters( 'optml_content_images_to_update', $found_images, $content );
  • inc/rest.php line 827
    do_action( 'optml_daily_sync' );
  • inc/settings.php line 136
    apply_filters( 'optml_default_settings', $this->default_schema );
  • inc/url_replacer.php line 73
    apply_filters( 'optml_dont_replace_url', false, $url );
  • inc/settings.php line 489
    apply_filters( 'optml_dont_trigger_settings_updated', false );
  • inc/manager.php line 820
    apply_filters( 'optml_extracted_urls', $extracted_urls );
  • inc/manager.php line 520
    apply_filters( 'optml_force_page_profiler', false );
  • inc/manager.php line 386
    apply_filters( 'optml_force_replacement_on', false );
  • inc/tag_replacer.php line 152
    apply_filters( 'optml_gif_to_video_flags', [ 'lazyload' => true, 'placeholder' => true, 'original-src' => true ] );
  • inc/lazyload_replacer.php line 627
    apply_filters( 'optml_iframe_lazyload_flags', [ 'gform_ajax_frame', '<noscript', 'recaptcha', '-src' ] );
  • inc/app_replacer.php line 214
    apply_filters( 'optml_ignore_data_opt_flag', [] );
  • inc/lazyload_replacer.php line 612
    apply_filters( 'optml_ignore_noscript_on', [ '<noscript' ] );
  • inc/url_replacer.php line 271
    apply_filters( 'optml_image_args', $args, $original_url );
  • inc/lazyload_replacer.php line 162
    apply_filters( 'optml_lazyload_bg_classes', [] );
  • inc/lazyload_replacer.php line 139
    apply_filters( 'optml_lazyload_bg_selectors', $all_watchers );
  • inc/lazyload_replacer.php line 231
    apply_filters( 'optml_lazyload_early_flags', [] );
  • inc/lazyload_replacer.php line 177
    apply_filters( 'optml_lazyload_images_skip', self::instance()->settings->get( 'skip_lazyload_images' ) );
  • inc/manager.php line 458
    apply_filters( 'optml_page_profiler_disable', false );
  • inc/v2/PageProfiler/Storage/ObjectCache.php line 40
    apply_filters( 'optml_page_profiler_object_cache_expiration', self::EXPIRATION );
  • inc/v2/PageProfiler/Storage/Transients.php line 37
    apply_filters( 'optml_page_profiler_transient_expiration', self::EXPIRATION_TIME );
  • inc/tag_replacer.php line 426
    apply_filters( 'optml_parse_resize_from_tag', [], $tag );
  • inc/app_replacer.php line 186
    apply_filters( 'optml_possible_lazyload_flags', [ 'skip-lazy', 'data-skip-lazy', 'data-opt-src' ] );
  • inc/app_replacer.php line 171
    apply_filters( 'optml_possible_src_attributes', [] );
  • inc/url_replacer.php line 272
    apply_filters( 'optml_processed_url', $url );
  • inc/admin.php line 186
    do_action( 'optml_purge_image_cache', $file );
  • inc/rest.php line 585
    apply_filters( 'optml_replace_image', $image['original'], [ 'width' => $image_sample['width'], 'height' => $image_sample['height'], 'quality' => $request->get_param( 'quality' ), ] );
  • inc/media_offload.php line 729
    apply_filters( 'optml_replacement_wp_query_args', [ 'post_type' => $post_types, 'post_status' => 'any', 'fields' => 'ids', 'posts_per_page' => $batch, 'update_post_meta_cache' => true, 'update_post_term_cache' => false, ] );
  • inc/url_replacer.php line 264
    apply_filters( 'optml_should_apply_dpr', $should_apply_dpr, $args, $url );
  • inc/url_replacer.php line 301
    apply_filters( 'optml_should_avif_ext', true, $ext, $original_url );
  • inc/manager.php line 690
    apply_filters( 'optml_should_ignore_image_tags', false );
  • inc/tag_replacer.php line 461
    apply_filters( 'optml_should_load_eager', '__return_true' );
  • inc/manager.php line 306
    apply_filters( 'optml_should_replace_page', false );
  • inc/app_replacer.php line 573
    apply_filters( 'optml_should_skip_strip_image_size', false, $url );
  • inc/app_replacer.php line 200
    apply_filters( 'optml_skip_optimizations_css_classes', [ 'skip-optimization' ] );
  • inc/tag_replacer.php line 304
    apply_filters( 'optml_tag_replace', $image_tag, $images['img_url'][ $index ], $new_url, $optml_args, $is_slashed, $tag );
  • inc/media_offload.php line 1806
    do_action( 'optml_updated_post', $post_id );
  • inc/manager.php line 595
    apply_filters( 'optml_url_post_process', $html );
  • inc/manager.php line 591
    apply_filters( 'optml_url_pre_process', $html );
  • inc/manager.php line 557
    apply_filters( 'optml_video_replace', $html );
  • inc/lazyload_replacer.php line 190
    apply_filters( 'optml_watcher_lz_classes', [] );
  • inc/media_rename/attachment_replace.php line 216
    apply_filters( 'update_attached_file', $new_file_path, $this->attachment_id );
  • inc/compatibilities/wp_fastest_cache.php line 45
    do_action( 'wpfc_clear_all_cache', true );
  • inc/compatibilities/wpml.php line 38
    apply_filters( 'wpml_element_trid', null, $attachment_id, 'post_attachment' );
  • inc/compatibilities/wpml.php line 41
    apply_filters( 'wpml_get_element_translations', null, $trid, 'post_attachment' );

Generated from Optimole's GPL-licensed source code. Hooks inside bundled third-party libraries are not listed.

Can't find the right hook?

We can build the customisation for you. Describe what you need: