Skip to content

Hooks Reference

padams edited this page Oct 14, 2026 · 4 revisions

Hooks Reference

Every action and filter PhotoPress provides, every WordPress core hook it uses, and the documented hooks and functions of other plugins it calls. Code links point to the 2.0.0 code (commit b6499f6).

PhotoPress uses documented public hooks and functions of WordPress and of other plugins. It does not read other plugins' tables or internal classes. Two exceptions: WP Offload Media documents only its settings, so PhotoPress uses its other hooks as its own add-ons do (Offload Media and CDN). Relevanssi has no filter for the post types and taxonomies it indexes, so PhotoPress saves those Relevanssi settings as its Indexing tab does, and removes only what it added (Image Search).

Hooks PhotoPress provides

Actions

Action Arguments Fires Code
photopress_post_changed int $id, array $context: files (URLs of files that changed), content (true when stored content was rewritten in place), gallery (true when the images its gallery shows changed) What a post or image shows changed without WordPress saving an edit. Used by the page cache and search index integrations. GalleryAdd.php#L801
photopress_image_terms_changed int $id, array $context: archives (archive URLs of the terms involved, before and after a rename), terms (the terms the image joined, left or lost, as <taxonomy>:<term ID>, absent from the term-change job), job (true when fired by the term-change job) An image joined or left a term of an image taxonomy, or one of its terms was renamed or deleted. TermChanges.php#L101
photopress_term_images_changed array $images: terms (term_taxonomy_ids) or images (IDs) A term with more than 25 images was renamed or deleted. TermChanges.php#L177
photopress_attachment_file_replaced int $id, string[] $replacements (old upload-relative paths mapped to new), int[] $rewritten (posts whose links were rewritten), array $options (reprocess_metadata) An image was given a new file through PhotoPress or Enable Media Replace. MediaRest.php#L388
photopress_attachment_files_removed int $id, string[] $urls A replacement deleted files the new file does not have. MediaRest.php#L364
photopress_image_files_rewritten int $id An image's files were written again under the same URLs: every size made again by the regenerate job, or the license written by the license job. images.php#L456, metadata.php#L1674
photopress_image_sizes_regenerated array $job The images.regenerate job finished. Files changed under the same URLs. images.php#L675
photopress_job_batch_started array $job A batch of a background job starts in this request. Jobs.php#L311
photopress_job_batch_ended array $job (status running, done or cancelled) A batch ends in this request. Jobs.php#L376
photopress_job_ended array $job A job is done or cancelled. Jobs.php#L391

Filters

Filter Value and arguments Purpose Code
photopress_job_max_load float $max (default 0.7 × processors) Load average above which paced jobs wait. Jobs.php#L429
photopress_job_min_memory int $bytes (default 300 MB) Available memory below which paced jobs wait. Jobs.php#L419
photopress_imagick_limits array $limits (memory, map in bytes; thread in the job), bool $job ImageMagick resource limits while WordPress makes image sizes. A value of 0 or less leaves that limit unchanged. images.php#L613
photopress_term_images_job bool $needed Whether the images of a renamed or deleted term with many images are processed one by one in a job. TermChanges.php#L179
photopress_replace_file_args array $args Arguments of POST /photopress/v1/media/{id}/file. MediaRest.php#L140
photopress_replace_file_response array $data, int $id, WP_REST_Request $request Response of a file replacement. MediaRest.php#L457
photopress_attachment_description string|null $description, int $id, string $file Description given to an image whose file is replaced. MediaRest.php#L726
photopress_metadata_tag_name string $name Alias of a metadata tag name before lookup. XmpReader.php#L167
photopress_metadata_tag_value mixed $value, string $name, array $all_xmp Value of a metadata tag. XmpReader.php#L177
photopress/taxonomies/defaultDefinitions array $taxonomies Default image taxonomy definitions for a new site. metadata.php#L1250

JavaScript events and properties

Name Kind Details Code
pp-slideshow-opened DOM event Dispatched on #lightbox-gallery when the full-screen slideshow opens. Bubbles. lightbox.js#L210
pp-slideshow-closed DOM event Dispatched on #lightbox-gallery when it closes. Bubbles. lightbox.js#L224
photopress-slideshow-change DOM event Dispatched on a slideshow's .photopress-gallery-slideshow element when the current image changes, and once when it starts. event.detail.index is the position, from 0. Does not bubble. slideshow.js#L286
element.photopressSlideshow property Set on each Gallery Slideshow block's root element: show( index ), next(), prev(), current(), destroy(). gallery-slideshow.js#L16

Action Scheduler hooks

PhotoPress schedules these actions in the Action Scheduler group photopress. They are internal. Do not schedule them yourself.

Hook Argument Runs
photopress_job_batch job ID One batch of a background job.
photopress_cdn_invalidate none Sends queued CloudFront invalidations.
photopress_offload_delete_objects bucket, region, keys, attempt Deletes replaced files from the bucket.
photopress_replace_settle attachment ID Undoes a file replacement that did not finish.
photopress_gallery_remove_retry post ID, image IDs, time of the deletion Removes deleted images from a post that was open in the editor. If the post is still open, it reschedules itself, for up to a day.

WordPress core hooks PhotoPress uses

Hook Type Code Purpose
plugins_loaded action photopress.php#L52, Scheduler.php#L47 Starts the plugin and decides whether to load Action Scheduler.
init action class-module.php#L50 Registers taxonomies, blocks, scripts and module hooks.
wp_loaded action metadata.php#L480, PageCache.php#L85, GalleryUpgrade.php#L39 Rebuilds rewrite rules when taxonomy URLs change. Empties the page cache once after an update. Starts the gallery upgrade job once per site.
admin_init, rest_api_init action class-module.php#L220, ImageSearch.php#L109 Registers settings (register_setting) and REST routes. With Relevanssi active, syncs its indexing settings with Images in search results.
admin_menu action class-module.php#L223 Adds the PhotoPress › Settings menu.
admin_enqueue_scripts action base.php#L15 Loads the settings app on PhotoPress screens only.
enqueue_block_editor_assets, enqueue_block_assets action gallery.php#L68, class-pp-framework.php#L146 Editor scripts and the shared block styles.
register_block_type_args filter gallery.php#L72 Adds PhotoPress attributes to core/gallery.
render_block_data filter gallery.php#L73 Loads a gallery's images in one query before it renders.
render_block_{$name} (core/gallery) filter gallery.php#L74 Applies layouts. Hides a gallery shown by a Gallery Slideshow block.
render_block filter slideshow.php#L29, metadata.php#L117 Marks slideshow galleries. Adds license JSON-LD.
pre_render_block filter ImageTemplates.php#L41, LegacyChildPages.php#L23 Renders Taxonomy and Child Pages Galleries. Renders a legacy Child Pages block as a Child Pages Gallery.
taxonomy_template_hierarchy, search_template_hierarchy filter ImageTemplates.php#L46, ImageSearch.php#L60 Offers the Image Archives and Image Search templates.
wp_footer action slideshow.php#L78, metadata.php#L124 Prints the full-screen slideshow container, and license JSON-LD for archives and image pages.
pre_get_posts action metadata.php#L166, ImageSearch.php#L58 Includes images in taxonomy archives and search results.
posts_where, posts_search filter metadata.php#L137, ImageSearch.php#L59 Limits queries to public images. Searches alt text and terms.
pre_option_{$option} (wp_attachment_pages_enabled) filter search.php#L79 The Attachment pages switch.
attachment_link filter search.php#L89 Links to the file when attachment pages are off.
add_attachment action metadata.php#L62, GalleryAdd.php#L67, TaxonomyGalleryPages.php#L50 Reads metadata into terms, alt text and description. Adds an upload to a gallery. Announces posts whose Taxonomy Gallery shows the latest images.
attachment_updated action PageCache.php#L83, TaxonomyGalleryPages.php#L51 Purges an edited image. Announces posts whose Taxonomy Gallery may show it.
delete_attachment action GalleryRemove.php#L51, TaxonomyGalleryPages.php#L52 Removes a deleted image from galleries. Announces posts whose Taxonomy Gallery may show it.
attachment_fields_to_edit filter metadata.php#L121 Shows a license write failure on the image.
wp_read_image_metadata filter metadata.php#L46 Reads the title and caption from XMP, and camera and exposure details.
pre_move_uploaded_file filter metadata.php#L112 Embeds the license before the upload is moved into place.
image_strip_meta filter metadata.php#L127 Whether resized images keep their metadata, from the metadata settings.
max_srcset_image_width filter metadata.php#L43 Allows sizes up to 3000 px in srcset.
wp_editor_set_quality filter images.php#L55 JPEG and WebP quality.
intermediate_image_sizes_advanced filter images.php#L56 Sizes turned off are not made.
wp_generate_attachment_metadata filter images.php#L58 Records the quality an image's sizes were made at.
wp_image_editors filter images.php#L59 Applies ImageMagick limits.
wp_get_missing_image_subsizes filter images.php#L479 Makes only the sizes a regenerate needs.
update_post_metadata, add_post_metadata, update_attached_file, image_make_intermediate_size filter images.php#L525 Held back during a regenerate, so the image is saved once all sizes exist.
upload_dir filter MediaRest.php#L310 Keeps a replacement file in the image's folder.
added_term_relationship, deleted_term_relationships, edit_terms, edited_term, pre_delete_term, delete_term action TermChanges.php#L55 Turns term changes into photopress_image_terms_changed and photopress_term_images_changed.
wp_after_insert_post, deleted_post action ChildPagesGallery.php#L32, TaxonomyGalleryPages.php#L48 Purges a parent page when its child pages change. Records a saved post's Taxonomy Galleries.
shutdown action GalleryRemove.php#L75, ImageSearch.php#L559 Batched gallery edits and search re-indexing at the end of the request.
rest_endpoints, rest_attachment_item_schema, rest_post_dispatch, rest_term_search_query, rest_prepare_attachment, rest_attachment_query, rest_queried_resource_route filter ImageTaxonomyRest.php#L62 Keeps image taxonomies out of anonymous REST responses.
rest_request_after_callbacks filter GalleryAdd.php#L66 Adds an uploaded image to its gallery once its sizes exist.
rest_namespace_index filter MediaRest.php#L81 WordPress and PhotoPress versions, for users who can upload.
widgets_init, widget_types_to_hide_from_legacy_widget_block action, filter metadata.php#L134 Registers the legacy widgets and hides them from the block widget inserter.
wp_sitemaps_post_types, wp_sitemaps_posts_query_args filter CoreSitemap.php#L22 Image pages in WordPress's sitemap.

Core functions PhotoPress depends on include register_taxonomy, register_block_type, wp_register_block_metadata_collection (WordPress 6.7+, when present), register_setting, register_rest_route, wp_set_object_terms, wp_generate_attachment_metadata, wp_update_attachment_metadata and flush_rewrite_rules.

Third-party hooks and functions

Each integration is inactive when its plugin is inactive.

Plugin Hooks and functions used Code Wiki
Action Scheduler (bundled) as_enqueue_async_action, as_schedule_single_action, as_unschedule_all_actions, as_get_scheduled_actions, as_has_scheduled_action; action action_scheduler_after_process_queue Scheduler.php, Jobs.php Background Jobs
Proxy Cache Purge filters varnish_http_purge_events, varnish_http_purge_events_full, varnish_http_purge_valid_post_statuses, vhp_purge_urls; fires the events photopress_purge_post and photopress_purge_all registered through them PageCache.php#L75 Page Cache
Relevanssi filters relevanssi_index_custom_fields, relevanssi_hits_filter; its settings relevanssi_index_post_types, relevanssi_index_taxonomies_list and relevanssi_index_image_files, read and saved as its Indexing tab does; functions relevanssi_do_query, relevanssi_index_doc, relevanssi_get_custom_fields Relevanssi.php, ImageSearch.php Image Search
Jetpack filters jetpack_page_sitemap_other_urls, jetpack_sitemap_image_skip_post, jetpack_sitemap_image_sitemap_item JetpackSitemap.php#L28 Sitemaps
Yoast SEO filters wpseo_sitemap_exclude_post_type, wpseo_sitemap_exclude_taxonomy, wpseo_sitemap_urlimages_term, wpseo_sitemaps_providers; interface WPSEO_Sitemap_Provider; WPSEO_Post_Type::is_post_type_accessible, is_post_type_indexable YoastSitemap.php#L27, YoastImagesSitemap.php Sitemaps
WP Offload Media its AS3CF_SETTINGS keys (documented); action as3cf_init, filters as3cf_pre_update_attachment_metadata and as3cf_object_meta, get_setting() and its bundled AWS SDK, used as its own add-ons use them OffloadMedia.php#L35 Offload Media and CDN
Enable Media Replace action enable-media-replace-upload-done EnableMediaReplace.php#L26 Replacing Image Files

Clone this wiki locally