Support » Plugin: Document Gallery » Unable to Add to Existing…

  • So, the plugin worked great to add my original files, but when I went back to add more, it won’t seem to do so.

    I edit the page
    I click edit on my existing gallery
    I click add to document gallery
    I select new document
    I see the new item in my gallery
    I click update document gallery
    I return to the edit page screen and the new document is not there.

    I can repeat this over and over with the same result.

    I am thus forced to delete the existing gallery, re-add everything (and new document) and save it as a new gallery.

Viewing 9 replies - 1 through 9 (of 9 total)
  • Plugin Author demur

    (@demur)

    Hi @grungyape!

    I’m sorry to hear that You’ve encountered some difficulties.
    Having run some tests on different environments, no glitches were found yet in the mentioned area. While I continue to look for possible problems in our code we need Your help to check if this is result of mismatch in Your WP mixture.
    According to Your description, there is a great probability to see JavaScript errors in browser console. Please open browser console (generally pressing F12 should do this) and proceed to the Edit Post tool with the corresponding Document Gallery instance post (or just refresh it if You are already there), then repeat all the steps You’ve mentioned to update gallery. Let us know if there are any errors in the Console.

    I am having the same exact problem when trying to add to an existing Document Gallery. Any solutions been found to this problem?

    • This reply was modified 2 years, 9 months ago by  justbecuz.

    @demur I followed your instructions and here is the error the browser console returned when I tried to add documents to an existing Document Gallery

    —-
    VM435:1 Uncaught SyntaxError: Unexpected token o in JSON at position 1
    at JSON.parse (<anonymous>)
    at Function.n.parseJSON (load-scripts.php?c=0&load[]=jquery-core,jquery-migrate,jquery-ui-core,utils,jquery-ui-widget,jquery…:4)
    at Function.a.parseJSON (load-scripts.php?c=0&load[]=jquery-core,jquery-migrate,jquery-ui-core,utils,jquery-ui-widget,jquery…:9)
    at HTMLDivElement.<anonymous> (gallery.min.js?wp-mce-4401-20160726:1)
    at Function.each (load-scripts.php?c=0&load[]=jquery-core,jquery-migrate,jquery-ui-core,utils,jquery-ui-widget,jquery…:2)
    at a.fn.init.each (load-scripts.php?c=0&load[]=jquery-core,jquery-migrate,jquery-ui-core,utils,jquery-ui-widget,jquery…:2)
    at B.<anonymous> (gallery.min.js?wp-mce-4401-20160726:1)
    at t.i [as fire] (tinymce.min.js?ver=4401-20160726:8)
    at B.fire (tinymce.min.js?ver=4401-20160726:8)
    at n.click (media_manager.min.js:10)
    n.parseJSON @ load-scripts.php?c=0&load[]=jquery-core,jquery-migrate,jquery-ui-core,utils,jquery-ui-widget,jquery…:4
    a.parseJSON @ load-scripts.php?c=0&load[]=jquery-core,jquery-migrate,jquery-ui-core,utils,jquery-ui-widget,jquery…:9
    (anonymous) @ gallery.min.js?wp-mce-4401-20160726:1
    each @ load-scripts.php?c=0&load[]=jquery-core,jquery-migrate,jquery-ui-core,utils,jquery-ui-widget,jquery…:2
    each @ load-scripts.php?c=0&load[]=jquery-core,jquery-migrate,jquery-ui-core,utils,jquery-ui-widget,jquery…:2
    (anonymous) @ gallery.min.js?wp-mce-4401-20160726:1
    i @ tinymce.min.js?ver=4401-20160726:8
    fire @ tinymce.min.js?ver=4401-20160726:8
    click @ media_manager.min.js:10
    click @ load-scripts.php?c=0&load[]=thickbox,hoverIntent,common,admin-bar,heartbeat,autosave,wp-ajax-respon…:415
    dispatch @ load-scripts.php?c=0&load[]=jquery-core,jquery-migrate,jquery-ui-core,utils,jquery-ui-widget,jquery…:3
    r.handle @ load-scripts.php?c=0&load[]=jquery-core,jquery-migrate,jquery-ui-core,utils,jquery-ui-widget,jquery…:3

    Plugin Author Dan Rossiter

    (@danrossiter)

    Hi Marsha,

    Can you please add define( 'SCRIPT_DEBUG', true ); to your wp-config.php file as described here, then re-post the error you posted above?

    -Dan

    • This reply was modified 2 years, 9 months ago by  Dan Rossiter.

    Hi Dan,

    Thanks for the response! I added the code to my wp-config.php and ran the ‘add to document gallery’ steps, and here is the error it returned

    VM693:1 Uncaught SyntaxError: Unexpected token o in JSON at position 1
    at JSON.parse (<anonymous>)
    at Function.n.parseJSON (jquery.js:4)
    at Function.jQuery.parseJSON (jquery-migrate.js:307)
    at HTMLDivElement.<anonymous> (gallery.js?wp-mce-4401-20160726:48)
    at Function.each (jquery.js:2)
    at jQuery.fn.init.each (jquery.js:2)
    at B.<anonymous> (gallery.js?wp-mce-4401-20160726:47)
    at t.i [as fire] (tinymce.min.js?ver=4401-20160726:8)
    at B.fire (tinymce.min.js?ver=4401-20160726:8)
    at n.click (media_manager.js:413)

    I look forward to your response.

    Plugin Author Dan Rossiter

    (@danrossiter)

    Thanks, Marsha! That helps.

    Ok, I’m going to need you to make a quick change to the Document Gallery code in order to get a better idea of what exactly is going on.

    In the same place where you updated the WP config, edit this file wp-content/plugins/document-gallery/assets/js/gallery.js adding console.log('shortcode: ' + decodeURIComponent($(this).data('shortcode'))); to line 48. That block should now look like this:

        /**
         * Handles necessary logic for when we're rendering gallery preview within visual editor.
         */
        function handleVisualEditor() {
            if (is_editor) {
                tinymce.PluginManager.add('dg', function (editor, url) {
                    editor.on('LoadContent update.dg undo', function (e) {
                        $(e.target.contentDocument).find('[data-wpview-type="dg"] [data-shortcode]').each(function () {
                            console.log('shortcode: ' + decodeURIComponent($(this).data('shortcode')));
                            retrieveGallery($.parseJSON(decodeURIComponent($(this).data('shortcode'))), $(this));
                        });
                    });
                });
            }
        }

    Once that’s done, I’ll be interested to know what shows up in the console directly before the error you posted. It should start with “shortcode: “.

    -Dan

    shortcode:{“order”:”DESC”,”orderby”:”name”,”attachment_pg”:”false”,”paginate”:”true”,”ids”:”1645,1644,1643,1428,1427,1668,1667,1666″}

    Still the same error
    VM3585:1 Uncaught SyntaxError: Unexpected token o in JSON at position 1
    at JSON.parse (<anonymous>)
    at Function.n.parseJSON (jquery.js:4)
    at Function.jQuery.parseJSON (jquery-migrate.js:307)
    at HTMLDivElement.<anonymous> (gallery.js?wp-mce-4403-20160901:49)
    at Function.each (jquery.js:2)
    at jQuery.fn.init.each (jquery.js:2)
    at B.<anonymous> (gallery.js?wp-mce-4403-20160901:47)
    at t.i [as fire] (tinymce.min.js?ver=4403-20160901:8)
    at B.fire (tinymce.min.js?ver=4403-20160901:8)
    at n.click (media_manager.js:413)

    Plugin Author Dan Rossiter

    (@danrossiter)

    Marsha,

    What browser are you using? The shortcode value seems to be valid and parses OK on my system, so I’m wondering if you have an unsupported browser.

    -Dan

    Hi Dan,

    I am using Chrome. I just tried it in FireFox and it worked. I updated the plugin to the latest upgrade and tried it again in Chrome, but it still didn’t work. I will use firefox to do my additions. Thanks for the suggestion

Viewing 9 replies - 1 through 9 (of 9 total)
  • The topic ‘Unable to Add to Existing…’ is closed to new replies.