Passing information to changepicturecallback
  • I'm using prettyPhoto to pop open YouTube videos, with a Facebook like button where the description field would be. The like button requires a URL for it to share, otherwise I'll get an error.

    The problem I'm currently having is figuring out what that URL should be when the user selects it. Doing so would be really easy if I could simply pass parameters to prettyPhoto's changepicturecallback, but the documentation doesn't mention a way to do so. Any ideas?

    An image of my prettyPhoto popup: http://lh5.ggpht.com/_XNoyY-rljvo/TGrFPIUiOSI/AAAAAAAAADE/s9-5tNwBbX8/prettyPhoto.png
  • You can overwrite _showContent function on the source code and change this line:

    settings.changepicturecallback();

    To:

    settings.changepicturecallback.apply(this, [matchedObjects]); // Callback!

    Or in any other way so you can choose what parameters should be passed to callback method.

    The javascript method apply allows you to change in which context a function should be called and also which parameters should be pass to it.
    Marcelo Moises
  • Actually the above doesn't work as expected, but the following will. Replace this lines in order to have the clicked element (that triggers the prettyPhoto) as the callback function context:

    $.prettyPhoto.open = function() {

    To:

    $.prettyPhoto.open = function(element) {

    _________________________________________
    Any:

    _showContent();

    To

    _showContent(element);

    _________________________________________
    _showContent = function(){

    To:

    _showContent = function(element){

    _________________________________________
    And finally, as shown before:

    settings.changepicturecallback(); // Callback!

    To:

    settings.changepicturecallback.apply(element, [matchedObjects]); // Callback!

    I know this maybe not exactly what you are looking for, but at least can give you an idea how to change the context which the callback function runs in.
    All these replacements were made on the development & uncompressed version of prettyPhoto
    Marcelo Moises
  • Question: Do anyone know how to change the codes for the prettyPhoto so Megavideo's can work in them too??? PLEASE HELP!!!! ^_^
  • so you need to change 2 things


    case 'youtube':
    correctSizes = _fitToViewport(movie_width,movie_height); // Fit item to viewport

    movie = 'http://www.megavideo.com/v/'+grab_param('v',pp_images[setPosition]);
    if(settings.autoplay) movie += "&autoplay=1";

    toInject = settings.flash_markup.replace(/{width}/g,correctSizes['width']).replace(/{height}/g,correctSizes['height']).replace(/{wmode}/g,settings.wmode).replace(/{path}/g,movie);
    break;







    and



    function _getFileType(itemSrc){
    if (itemSrc.match(/megavideo\.com/i)) {
    return 'youtube';

  • please update code to megavideo not work for me :(

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!