Skip to content

Instantly share code, notes, and snippets.

View jfacemyer's full-sized avatar

jfacemyer jfacemyer

View GitHub Profile
@jfacemyer
jfacemyer / divi-lightbox-snippet-for-functions.php
Last active January 25, 2017 19:52 — forked from CoachBirgit/divi-lightbox-snippet-for-functions.php
DIVI: add lightbox to regular content images
/* add .et_pb_lightbox_image clss to content images */
add_filter('the_content', 'divi_add_lightbox', 99);
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"$6>';
$content = preg_replace($pattern, $replacement, $content);
return $content;
}