-
Notifications
You must be signed in to change notification settings - Fork 3.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Gallery with mixed content types #146
Comments
To make it open on clicked element, you should initialize it from DOM elements, currently you're initializing it from the |
If its not initializing from items, how do you define the type of each element with mixed content? |
You may define type of popup via mfp-TYPE CSS class, check http://dimsemenov.com/plugins/magnific-popup/documentation.html#content_types |
I've missed that in documentation, my bad. Thank you! |
As a third option you may do a manual check for type, e.g.: $('.image-link').magnificPopup({
type:'image',
callbacks: {
elementParse: function(item) {
// Function will fire for each target element
// "item.el" is a target DOM element (if present)
// "item.src" is a source that you may modify
if(something) {
item.type = 'image';
} else {
item.type = 'video';
}
}
}
}); |
@dimsemenov hi! I tried: if(item.el.context.className == 'portfolio-data magnificpopup-portfolio-video') { item.type = 'video'; } else { item.type = 'image'; } but only image works, not the video unfortunately. There is an error in Chrome console: Uncaught TypeError: Property 'getVideo' of object [object Object] is not a function. Any tips what's wrong? |
Ups, sorry, that works: if(item.el.context.className == 'portfolio-data magnificpopup-portfolio-video') { item.type = 'iframe'; } else { item.type = 'image'; }. If this code is OK, I mean in terms of performance? . gallery:{enabled:true}, is enabled. Any tips please? |
its been a while on this thread but thought i'd update in case anybody else comes across this, gallery:{enabled:true} is working for me using this solution. |
For anyone coming in through Google. Youtube / Vimeo / etc videos don't load properly locally (as in running your site from |
This works for non-image or non-video elements too. You have to provide your css for white-popup. Cheers! 🍷 |
in the anchor tag put data-itemtype='image' for photo type or data-itemtype="iframe" for video type |
Gallery with mixed content types, it always opens the first element, should open the clicked element
http://codepen.io/anon/pen/KvcCJ
The text was updated successfully, but these errors were encountered: