• Resolved Daniel Maier

    (@demaier)


    I already contacted the support regarding this bug but have not received a fix. I am posting here seeking help from the community.

    On the new version of NextGEN Gallery the following files have been added:

    /nextgen-gallery/products/photocrati_nextgen/modules/attach_to_post/static/igw.js
    /nextgen-gallery/products/photocrati_nextgen/modules/attach_to_post/static/igw.min.js

    And when trying to edit the permalink of an attached image (Media > Library > ‘choose an image that has been attached/uploaded to a page’ > Edit” under “Permalink” click “Edit”, it will not work.

    The error displayed is:

    Uncaught TypeError: Cannot read property 'replace' of undefined
        at window.fix_tb_dimensions (https://example.com/wp-content/plugins/nextgen-gallery/products/photocrati_nextgen/modules/attach_to_post/static/igw.min.js?ver=2.1.56:1:424)
        at HTMLDocument.<anonymous> (https://example.com/wp-content/plugins/nextgen-gallery/products/photocrati_nextgen/modules/attach_to_post/static/igw.min.js?ver=2.1.56:1:548)
        at i (https://example.com/wp-includes/js/jquery/jquery.js?ver=1.12.4:2:27449)
        at Object.fireWith [as resolveWith] (https://example.com/wp-includes/js/jquery/jquery.js?ver=1.12.4:2:28213)
        at Function.ready (https://example.com/wp-includes/js/jquery/jquery.js?ver=1.12.4:2:30006)
        at HTMLDocument.K (https://example.com/wp-includes/js/jquery/jquery.js?ver=1.12.4:2:30368)

    This is the “fix_tb_dimensions” function on “igw.js”:

    window.fix_tb_dimensions = function(){
        var $button     = $('.ngg-add-gallery');
        var href        = $button.attr('href');
        var dimensions  = get_igw_dimensions();
        href = href.replace(/width=\d+/, 'width='+dimensions.width.toString());
        href = href.replace(/height=\d+/, 'height='+dimensions.height.toString());
    
        $button.attr('href', href);
    };
    fix_tb_dimensions();

    So the “href.replace” here is throwing that exception as far I can understand this.

    Please, if you know how to fix this, let us know. Thanks!

Viewing 5 replies - 1 through 5 (of 5 total)
  • Thread Starter Daniel Maier

    (@demaier)

    Here’s the entire igw.js file:

    (function($){
        setTimeout(function(){
            $(function(){
    
                window.get_igw_dimensions = function(){
                    var $button     = $('.ngg-add-gallery');
                    var href        = $button.attr('href');
                    var win = jQuery(top);
                    var winWidth    = win.width();
                    var winHeight   = win.height();
                    var popupWidth  = 1200;
                    var popupHeight = 600;
                    var minWidth    = 800;
                    var minHeight   = 600;
                    var maxWidth    = winWidth  - (winWidth  * 0.05);
                    var maxHeight   = winHeight - (winHeight * 0.05);
    
                    if (maxWidth    < minWidth)  { maxWidth    = winWidth-10  }
                    if (maxHeight   < minHeight) { maxHeight   = winHeight-10 }
                    if (popupWidth  > maxWidth)  { popupWidth  = maxWidth;  }
                    if (popupHeight > maxHeight) { popupHeight = maxHeight; }
    
                    return {
                        width: popupWidth,
                        height: popupHeight,
                        top: (winHeight-popupHeight)/2,
                        left: (winWidth-popupWidth)/2
                    };
                };
    
                window.fix_tb_dimensions = function(){
                    var $button     = $('.ngg-add-gallery');
                    var href        = $button.attr('href');
                    var dimensions  = get_igw_dimensions();
                    href = href.replace(/width=\d+/, 'width='+dimensions.width.toString());
                    href = href.replace(/height=\d+/, 'height='+dimensions.height.toString());
    
                    $button.attr('href', href);
                };
                fix_tb_dimensions();
    
                // Restore Thickbox functionality
                window.wp_tb_position = window.tb_position;
                window.tb_position = function(){
                    var src = $("#TB_window iframe").attr('src');
                    if (src && src.match('attach_to_post')) {
                        var dimensions = get_igw_dimensions();
                        $("#TB_window").css({
                            width:  dimensions.width.toString()+ "px",
                            height: dimensions.height.toString()+"px",
                            'top':  dimensions.top.toString()+"px",
                            'left': dimensions.left.toString()+"px"
                        });
                        $('#TB_window iframe').css({
                            width: '100%',
                            height: '93%'
                        });
                    }
                    else {
                        window.wp_tb_position();
                    }
                };
            });
        });
    })(jQuery);

    I see that on line 18 and 19 the following is missing semicolon after maxWidth and maxHeight:

    if (maxWidth    < minWidth)  { maxWidth    = winWidth-10  }
    if (maxHeight   < minHeight) { maxHeight   = winHeight-10 }

    Also after window.fix_tb_dimensions function you immediately call the function “fix_tb_dimensions();”. Is this correct?

    Thread Starter Daniel Maier

    (@demaier)

    I tried re-processing the minified file with igw.js and it didn’t work. The issue persists.

    • This reply was modified 9 years, 7 months ago by Daniel Maier.
    • This reply was modified 9 years, 7 months ago by Daniel Maier.
    Plugin Contributor Imagely

    (@imagely)

    @demaier – I can’t connect your username to your email message, but I believe we sorted this out with you. We’ll be including a fix for this in the next update. Could you confirm here you received our message? 🙂

    Thanks!
    Becky

    Thread Starter Daniel Maier

    (@demaier)

    Hi Becky @imagely,

    I used a different email address on the support email message.
    Yes, I did receive the message. Thank you!

    Plugin Contributor photocrati

    (@photocrati)

    @demaier – Thanks for the confirmation.

    – Cais.

Viewing 5 replies - 1 through 5 (of 5 total)

The topic ‘Uncaught TypeError: Cannot read property ‘replace’ of undefined’ is closed to new replies.