• Resolved benjamin879

    (@benjamin879)


    Hi,

    Thanks for a great plugin.

    I’ve edited the NextGen gallery template file so that the Public Uploader shortcode is inserted at the bottom of each Gallery page.

    The gallery template I edited is:
    “domain_name”/wp-content/plugins/nextgen-gallery-plus/modules/nextgen_pro_masonry/templates/index.php

    As a final step, I need to insert a variable into the shortcode. The variable I want to insert is the ID of the current gallery page being viewed INTO the public uploader shortcode where it asks for gallery ID.

    Unfortunately I’ve never played with php before. So far I have this solution:

    <?php echo do_shortcode(“[ngg_uploader id=<?php esc_attr_e($displayed_gallery_id); ?>]”); ?><?php $this->end_element(); ?>

    It successfully displays the uploader form, but the images are not uploading to the correct gallery ID, so its not working properly.

    Do you know how I can change this to make it work?

    Your help would be much appreciated. Thank you

    https://wordpress.org/plugins/nextgen-public-uploader/

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author Michael Beckwith

    (@tw2113)

    The BenchPresser

    Have you verified that the image(s) are uploaded at all? Also have you verified that the $displayed_gallery_id is holding the gallery ID you’re expecting.

    Lastly it looks like your PHP may be a bit off. Try the following.

    <?php echo do_shortcode("[ngg_uploader id=" . esc_attr__( $displayed_gallery_id ) . "]"); ?><?php $this->end_element(); ?>

    This way it’s not echoing the ID before it can be used with the do_shortcode().

    Thread Starter benjamin879

    (@benjamin879)

    Thanks for your quick reply Michael, I adopted your improved code.

    When an image is attempted for upload, the following error message displays on the refreshed page: Failure in database, no gallery path set.

    The problem is that $displayed_gallery_id is not holding the gallery ID I’m expecting. I’m expecting a simple ID like ‘1’, ‘2’, ‘3’, etc (as used generally in the public uploader), however instead this variable is holding long values like:
    038b5ea662651a31d2c6178cf68f1f31

    It seems I’m referencing the wrong variable – but I can’t find what variable the public uploader is referencing for gallery ID. I saw the variable ‘gid’ mentioned in the public uploader php file, and the values for ‘gid’ in the phpmyadmin database seem to match the values that the public uploader is expecting me to put into the shortcake (like 1,2,3)…but I can’t seem to reference the gid variable. Maybe you know the correct variable name?

    Plugin Author Michael Beckwith

    (@tw2113)

    The BenchPresser

    Here’s how we grab the ID in the current version of the plugin: https://plugins.trac.wordpress.org/browser/nextgen-public-uploader/trunk/inc/class.npu_uploader.php#L26

    Note this is likely changing in the next version, which is getting some action done on recently. Hopefully some simplification of the codebase as a whole, and confirmed compatibility with the latest NGG. No release date yet, though. Still testing things.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘How to get Gallery ID?’ is closed to new replies.