Return content early if not images found

This filter adds attributes for the lightbox, but it is resource-intensive. Returning early if there are no images saves those resources.
This commit is contained in:
Tetrakern 2023-12-16 21:39:43 +01:00
parent 820753f148
commit 1fdcff147f

View File

@ -531,7 +531,7 @@ add_filter( 'the_content', 'fictioneer_add_chapter_paragraph_id', 10, 1 );
*/
function fictioneer_add_lightbox_to_post_images( $content ) {
if ( empty( $content ) ) {
if ( empty( $content ) || strpos( $content, '<img' ) === false ) {
return $content;
}