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.
// 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
-
optml_clear_cache
action/** * Clear cache when storing profile data. */ do_action( 'optml_clear_cache', $current_url ); -
themeisle_sdk_current_date
filter/** * The current date. */ apply_filters( 'themeisle_sdk_current_date', new \DateTime( 'now' ) ); -
/** * Action triggered after the attachment file is renamed. */ do_action( 'optml_after_attachment_url_replace', $this->attachment_id, $old_url, $new_url ); -
optml_capture_at_shutdown
filter/** * 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 ); -
optml_captured_page_html
filter/** * Filters the captured page HTML before Optimole processes it. */ apply_filters( 'optml_captured_page_html', $html ); -
optml_keep_existing_sizes
filter/** * Filters whether Optimole leaves an image's existing sizes attribute * unchanged. */ apply_filters( 'optml_keep_existing_sizes', $keep, $tag ); -
optml_page_profile_id
filter/** * 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 ); -
optml_page_profiler_storage
filter/** * 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 ); -
/** * 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 ); -
optml_settings_updated
action/** * Fires when Optimole settings are updated. */ do_action( 'optml_settings_updated' ); -
/** * The black friday sale period flag. */ apply_filters( 'themeisle_sdk_is_black_friday_sale', false ); -
optml_log
actiondo_action( 'optml_log', 'can_lazyload_for: ' . $url . ' ' . $tag ); -
optml_content_url
filterapply_filters( 'optml_content_url', $value->featured_image ); -
optml_default_crop
filterapply_filters( 'optml_default_crop', [] ); -
apply_filters( 'optml_offload_duplicated_images', [], $content_id ); -
optml_replacer_setup
actiondo_action( 'optml_replacer_setup' ); -
do_action( 'cache_enabler_clear_site_cache' ); -
apply_filters( 'optml_ensure_source_attachment_id', $id ); -
optml_force_replacement
filterapply_filters( 'optml_force_replacement', false ); -
optml_register_conflicts
filterapply_filters( 'optml_register_conflicts', [] ); -
swcfpc_purge_cache
actiondo_action( 'swcfpc_purge_cache', [ $location ] ); -
themeisle_internal_page
actiondo_action( 'themeisle_internal_page', OPTML_PRODUCT_SLUG, 'dashboard' ); -
breeze_clear_all_cache
actiondo_action( 'breeze_clear_all_cache' ); -
do_action( 'cache_enabler_clear_page_cache_by_url', $location ); -
litespeed_purge_url
actiondo_action( 'litespeed_purge_url', $location ); -
optimole_offload_batch
filterapply_filters( 'optimole_offload_batch', 20 ); -
apply_filters( 'optml_additional_html_classes', [] ); -
optml_after_setup
actiondo_action( 'optml_after_setup' ); -
optml_apply_watermark_for
filterapply_filters( 'optml_apply_watermark_for', true, $url ); -
optml_attachment_renamed
actiondo_action( 'optml_attachment_renamed', $this->attachment_id ); -
optml_attachment_replaced
actiondo_action( 'optml_attachment_replaced', $this->attachment_id ); -
apply_filters( 'optml_conflicting_active_plugins', $conflicting_plugins ); -
apply_filters( 'optml_conflicting_defined_plugins', $plugins ); -
optml_content_images_tags
filterapply_filters( 'optml_content_images_tags', $content, $images ); -
apply_filters( 'optml_content_images_to_update', $found_images, $content ); -
optml_daily_sync
actiondo_action( 'optml_daily_sync' ); -
optml_default_settings
filterapply_filters( 'optml_default_settings', $this->default_schema ); -
optml_dont_replace_url
filterapply_filters( 'optml_dont_replace_url', false, $url ); -
apply_filters( 'optml_dont_trigger_settings_updated', false ); -
optml_extracted_urls
filterapply_filters( 'optml_extracted_urls', $extracted_urls ); -
optml_force_page_profiler
filterapply_filters( 'optml_force_page_profiler', false ); -
optml_force_replacement_on
filterapply_filters( 'optml_force_replacement_on', false ); -
optml_gif_to_video_flags
filterapply_filters( 'optml_gif_to_video_flags', [ 'lazyload' => true, 'placeholder' => true, 'original-src' => true ] ); -
optml_iframe_lazyload_flags
filterapply_filters( 'optml_iframe_lazyload_flags', [ 'gform_ajax_frame', '<noscript', 'recaptcha', '-src' ] ); -
optml_ignore_data_opt_flag
filterapply_filters( 'optml_ignore_data_opt_flag', [] ); -
optml_ignore_image_link
filterapply_filters( 'optml_ignore_image_link', false, $src ); -
optml_ignore_noscript_on
filterapply_filters( 'optml_ignore_noscript_on', [ '<noscript' ] ); -
optml_image_args
filterapply_filters( 'optml_image_args', $args, $original_url ); -
optml_keep_copyright
filterapply_filters( 'optml_keep_copyright', false ); -
optml_lazyload_bg_classes
filterapply_filters( 'optml_lazyload_bg_classes', [] ); -
optml_lazyload_bg_selectors
filterapply_filters( 'optml_lazyload_bg_selectors', $all_watchers ); -
optml_lazyload_early_flags
filterapply_filters( 'optml_lazyload_early_flags', [] ); -
optml_lazyload_images_skip
filterapply_filters( 'optml_lazyload_images_skip', self::instance()->settings->get( 'skip_lazyload_images' ) ); -
optml_page_profiler_disable
filterapply_filters( 'optml_page_profiler_disable', false ); -
apply_filters( 'optml_page_profiler_object_cache_expiration', self::EXPIRATION ); -
apply_filters( 'optml_page_profiler_transient_expiration', self::EXPIRATION_TIME ); -
optml_parse_resize_from_tag
filterapply_filters( 'optml_parse_resize_from_tag', [], $tag ); -
apply_filters( 'optml_possible_lazyload_flags', [ 'skip-lazy', 'data-skip-lazy', 'data-opt-src' ] ); -
apply_filters( 'optml_possible_src_attributes', [] ); -
optml_processed_url
filterapply_filters( 'optml_processed_url', $url ); -
optml_purge_image_cache
actiondo_action( 'optml_purge_image_cache', $file ); -
optml_replace_image
filterapply_filters( 'optml_replace_image', $image['original'], [ 'width' => $image_sample['width'], 'height' => $image_sample['height'], 'quality' => $request->get_param( 'quality' ), ] ); -
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, ] ); -
optml_should_apply_dpr
filterapply_filters( 'optml_should_apply_dpr', $should_apply_dpr, $args, $url ); -
optml_should_avif_ext
filterapply_filters( 'optml_should_avif_ext', true, $ext, $original_url ); -
apply_filters( 'optml_should_ignore_image_tags', false ); -
optml_should_load_eager
filterapply_filters( 'optml_should_load_eager', '__return_true' ); -
optml_should_replace_page
filterapply_filters( 'optml_should_replace_page', false ); -
apply_filters( 'optml_should_skip_strip_image_size', false, $url ); -
apply_filters( 'optml_skip_optimizations_css_classes', [ 'skip-optimization' ] ); -
optml_tag_replace
filterapply_filters( 'optml_tag_replace', $image_tag, $images['img_url'][ $index ], $new_url, $optml_args, $is_slashed, $tag ); -
optml_updated_post
actiondo_action( 'optml_updated_post', $post_id ); -
optml_url_post_process
filterapply_filters( 'optml_url_post_process', $html ); -
optml_url_pre_process
filterapply_filters( 'optml_url_pre_process', $html ); -
optml_video_replace
filterapply_filters( 'optml_video_replace', $html ); -
optml_watcher_lz_classes
filterapply_filters( 'optml_watcher_lz_classes', [] ); -
update_attached_file
filterapply_filters( 'update_attached_file', $new_file_path, $this->attachment_id ); -
wpfc_clear_all_cache
actiondo_action( 'wpfc_clear_all_cache', true ); -
wpml_element_trid
filterapply_filters( 'wpml_element_trid', null, $attachment_id, 'post_attachment' ); -
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: