Created
June 18, 2013 20:09
-
-
Save ajtroxell/5808855 to your computer and use it in GitHub Desktop.
Using Magnific Popup with Wordpress Now, from: http://ajtroxell.com/using-magnific-popup-with-wordpress-now/
This file contains hidden or 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 title back to images | |
*/ | |
function pexeto_add_title_to_attachment( $markup, $id ){ | |
$att = get_post( $id ); | |
return str_replace('<a ', '<a title="'.$att->post_title.'" ', $markup); | |
} | |
add_filter('wp_get_attachment_link', 'pexeto_add_title_to_attachment', 10, 5); |
This file contains hidden or 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
<link rel="stylesheet" href="<?php echo get_stylesheet_directory_uri(); ?>/magnific-popup.css"> |
This file contains hidden or 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
$(document).ready(function() { | |
//Initialize for inline images | |
$('.pop').magnificPopup({type:'image'}); | |
//Initialize for wordpress galleries | |
$('.gallery').magnificPopup({ | |
delegate: 'a', | |
type: 'image', | |
gallery: { | |
enabled: true | |
} | |
}); | |
}); |
This file contains hidden or 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
// initialize magnific popup galleries with titles and descriptions | |
$('.gallery').magnificPopup({ | |
callbacks: { | |
open: function() { | |
$('.mfp-description').append(this.currItem.el.attr('title')); | |
}, | |
afterChange: function() { | |
$('.mfp-description').empty().append(this.currItem.el.attr('title')); | |
} | |
}, | |
delegate: 'a', | |
type: 'image', | |
image: { | |
markup: '<div class="mfp-figure">'+ | |
'<div class="mfp-close"></div>'+ | |
'<div class="mfp-img"></div>'+ | |
'<div class="mfp-bottom-bar">'+ | |
'<div class="mfp-title"></div>'+ | |
'<div class="mfp-description" style="text-align: left;font-size: 12px;line-height: 16px;color: #f3f3f3;word-break: break-word;padding-right: 36px;"></div>'+ | |
'<div class="mfp-counter"></div>'+ | |
'</div>'+ | |
'</div>', | |
titleSrc: function(item) { | |
return '<strong>' + item.el.find('img').attr('alt') + '</strong>'; | |
} | |
}, | |
gallery: { | |
enabled: true, | |
navigateByImgClick: true | |
} | |
}); |
I am linking to your resource page here:
http://easywebdesigntutorials.com/adding-a-lightbox-to-wordpress-without-using-a-plugin/
Thank you for adding the code!
Nice
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hey
Is there a way to only add code to the functions file + the extra files to get it to work?
As in not having to add code to the header and footer.