Tagged: Blog, blog post element, Lightbox, links
-
AuthorPosts
-
January 26, 2022 at 12:52 pm #1337264
Dear Support-Team,
I have searched the forums and tried a few things already. Also made some experiments with
?iframe=true
. None of them worked. So the question to you professionals: Is it possible to use a lightbox in the blog post element?I have very short posts that are loaded if a link is klicked. It would be much more comfortable to just open them in a lightbox and not always load a new page. However, by default, the post image and title link always link to a page. Can I change this somehow?
Glad to get some information about this. Thanks a lot!
Best regards,
DanielJanuary 27, 2022 at 5:41 am #1337402Hey spooniverse,
Thank you for the inquiry.
This option is not available out of the box, but it is possible. Unfortunately, creating this kind of functionality is beyond the scope of support. You may need look for external help such as hiring a freelance developer.
// https://kriesi.at/contact/customization
Best regards,
IsmaelJanuary 27, 2022 at 7:20 am #1337421show me a test page where you like to open those links in a lightbox.
is it a page like this:
https://kriesi.at/themes/enfold-2017/elements/blog-posts/
or
https://kriesi.at/themes/enfold-2017/blog/blog-default/
And you want to open not the posts on a new page but as iframe in a lightbox?January 27, 2022 at 10:25 am #1337459Hey Guenni007,
it is not about the normal blog. I would like to use a ALB blog post element (as in your first link) and display posts of a certain category on a page with the option “blog grid”. If the image or title of the shown entries is clicked the posts should be loaded as iframe in a lightbox, correct. Any ideas?
Thank you for your interest! And thanks Ismael for pointing out that it can be made somehow.
All the best,
DanielJanuary 27, 2022 at 4:38 pm #1337555you can see here on top of that page a masonry with portfolio links.
If you click to open it – it will open that portfolio in a lightbox ( but the complete page )
https://webers-testseite.de/lightboxes/
Is it the way you like to have it?January 27, 2022 at 4:43 pm #1337558This is the way I would like to have it, yes! But with normal posts (not portfolio entries). And for some reason I would like to use the blog post element (not a masonry). Or can’t it be made with the blog post element?
Thank you for your effort already!
January 27, 2022 at 5:06 pm #1337562i gave to the alb element itself a custom-class ( in my case ) : open-in-lightbox
then i put this to child-theme functions.php:
function posts_iframe_popup() { ?> <script type="text/javascript"> (function($) { $(window).on('load', function(){ $('.open-in-lightbox a.av-masonry-entry').magnificPopup({ type:'iframe', mainClass: 'spezial-masonries', }); $('.open-in-lightbox a.slide-image, .open-in-lightbox .slide-entry-title > a').magnificPopup({ type:'iframe', mainClass: 'spezial-blogposts', }); }); })(jQuery); </script> <?php } add_action('wp_footer', 'posts_iframe_popup');
the mainClass is only to have a way to select f.e. the iframe-scaler specifically for that usage – you will have that class on mfp-wrap container.
to have the links from both ( the image and the slide title – we have in that rule two selectors).PS : on that blog-posts the first link “iframe-lightbox” leads to an iframe which can open a new iframe on top :lol:
January 27, 2022 at 7:13 pm #1337571Perfect! Thanks a lot, Guenni007!
Any idea on how to hide the head and footer on those posts? In my case it is a custom post type. Should be possible with a modification to the single.php file of the CPT – what do you think?
Even better would be a script to hide head and footer only if the entry is shown inside an iframe? Do you think that is possible?
Best regards,
DanielJanuary 27, 2022 at 9:26 pm #1337579try:
function posts_iframe_popup() { ?> <script type="text/javascript"> (function($) { if (top === self) { // no frame } else { //frame $('#header, #footer, #socket').hide(); $('#main').attr('style', 'padding-top: 0px !important'); }; $(window).on('load', function(){ $('.open-in-lightbox a.av-masonry-entry').magnificPopup({ type:'iframe', mainClass: 'spezial-masonries', }); $('.open-in-lightbox a.slide-image, .open-in-lightbox .slide-entry-title > a').magnificPopup({ type:'iframe', mainClass: 'spezial-blogposts', }); }); })(jQuery); </script> <?php } add_action('wp_footer', 'posts_iframe_popup');
see testpage: https://webers-testseite.de/lightboxes/
January 27, 2022 at 9:40 pm #1337580if you like to have no sidebar on the iframe replace that part above that checks if frame or not with:
if (top === self) { // no frame } else { //frame $('#header, #footer, #socket, .sidebar').hide(); $('#main').attr('style', 'padding-top: 0px !important'); $('.container .av-content-small').css('width', '100%'); $('.content').css('border-right', 'none'); };
and if you like to have the link of the concerning categorie aswell open in a lightbox – extend the selectors to:
$('.open-in-lightbox a.slide-image, .open-in-lightbox .blog-categories > a, .open-in-lightbox .slide-entry-title > a').magnificPopup({
January 28, 2022 at 2:27 am #1337598Wow! That is beyond my expectations. Thank you!
Should be everything I need. Thread may be closed.
January 28, 2022 at 9:22 am #1337641Not for that –
maybe you change from.hide() to .remove()
that is somehow a matter of tasteJanuary 28, 2022 at 11:41 am #1337678Why? What is your preference?
January 28, 2022 at 12:09 pm #1337692the first only hides it (sets it to display: none), but it remains in the DOM – the second removes these containers. Nevertheless, the adjustment of the css (especially the padding-top) must still be done.
January 28, 2022 at 4:12 pm #1337762January 28, 2022 at 8:58 pm #1337802Dear @guenni007, last question: Do you think it is possible to load the script only for a certain viewport? Let’s say on mobile I would use a normal link (open the entry) and from tablet-size on I would load the script and use the added lightbox. Any ideas?
January 28, 2022 at 11:55 pm #1337808should it be prevented for real mobile devices or for small screen sizes?
If it is for small screen sizes is only to avoid ? it must respond to resize?January 29, 2022 at 12:03 am #1337809try:
function posts_iframe_popup() { ?> <script type="text/javascript"> (function($) { if (top === self) { // no frame } else { //frame $('#header, #footer, #socket').remove(); $('#main').attr('style', 'padding-top: 0px !important'); }; $(window).on('load', function(){ $('.open-in-lightbox a.av-masonry-entry').magnificPopup({ type:'iframe', disableOn: 768, mainClass: 'spezial-masonries', }); $('.open-in-lightbox a.slide-image, .open-in-lightbox .slide-entry-title > a').magnificPopup({ type:'iframe', disableOn: 768, mainClass: 'spezial-blogposts', }); }); })(jQuery); </script> <?php } add_action('wp_footer', 'posts_iframe_popup');
play with the 768 value to get what you like to have f.e.:
if you take 769
you have that case where an ipad mini (1024×768) will open on portrait the new page without lightbox – if you tilt it to landscape – it will open the lightbox.
However, it will not undergo any change after the link is opened.January 29, 2022 at 4:08 pm #1337838Thank you! Works as aspected. Learnt a lot from your code.
January 30, 2022 at 4:15 am #1337881Hi,
Great, I’m glad that @guenni007 could help you out :-)
Please let us know if you should need any further help on the topic or if we can close it.
Best regards,
RikardJanuary 31, 2022 at 12:33 pm #1338039You may close this.
And thanks again to Guenni007January 31, 2022 at 1:50 pm #1338048Hi,
Glad Guenni007 was able to help, if you have any further questions please create a new thread and we will gladly try to help you. Thank you for using Enfold.Best regards,
Mike -
AuthorPosts
- The topic ‘Lightbox for Blog Post Element’ is closed to new replies.