I am working on a WordPress theme and I was wondering if there is a way of opening images in Magnific Popup which are inserted on a post body by the editor. So, any image I insert in a post through TinyMCE editor will open on Magnific Popup when clicked on the front end.
相关问题
- Reference for inserted element through execCommand
- HTML form is not sending $_POST values
- Display product ACF field value in Woocommerce tra
- Adding a custom button after add to cart button in
- How to add a “active” class to a carousel first el
There are a few different approaches to this question. I've outlined a couple below.
Option 1
Filter the content and apply a HTML attribute that can be targeted with Magnific Popup.
We can take a cue from this article and leverage
the_content
hook.functions.php
Add the following to
functions.php
.JS
View Example
Option 2
Another option would be to selectively assign a CSS class to links which should be part of the image gallery.
JS
View Example