Forked from CoachBirgit/divi-lightbox-snippet-for-functions.php
Created
October 5, 2019 12:04
-
-
Save phirebase/b477510ceb5cdbbe704beb6e0e4a4e66 to your computer and use it in GitHub Desktop.
DIVI: add lightbox to regular content images
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* add .et_pb_lightbox_image clss to content images */ | |
add_filter('the_content', 'divi_add_lightbox'); | |
function divi_add_lightbox($content) { | |
global $post; | |
$pattern ="/<a(.*?)href=('|\")(.*?).(bmp|gif|jpeg|jpg|png)('|\")(.*?)>/i"; | |
$replacement = '<a$1href=$2$3.$4$5 class="et_pb_lightbox_image" title="'.$post->post_title.'"$6>'; | |
$content = preg_replace($pattern, $replacement, $content); | |
return $content; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment