WordPress.org

Support

Support » Plugins and Hacks » WP User Frontend » [Plugin: WP User Frontend] Image attachment not working error in JS file

[Plugin: WP User Frontend] Image attachment not working error in JS file

Viewing 13 replies - 1 through 13 (of 13 total)
  • Plugin Author Tareq Hasan

    @tareq1988

    do you have this file?
    /wp-includes/js/jquery/ui/jquery.ui.sortable.min.js

    I just checked yes I have that

    I comment the sortable function out it seem to cause issues

    I think this is the same as my issue:

    http://wordpress.org/support/topic/plugin-wp-user-frontend-cannot-upload-any-images

    Was it resolved?

    Hi folks!
    if nothing happens when you click on the add image button, and you get no js error at all (like it happened to me) this is probably because you are loading the shortcodes from a php file using a page template.

    For example, I was using this in my template file:
    <?php echo do_shortcode('[wpuf_addpost]'); ?>

    But, the attachment.php has this logic for loading the scripts:
    if ( has_shortcode( 'wpuf_addpost' ) || has_shortcode( 'wpuf_edit' ) || has_shortcode( 'wpuf_dashboard' ) )

    and I found out that it returns false if you load the shortcode from php.
    I think this is a bug and should be fixed.
    Cheers!

    And the resolution to the problem is to do what, ablok?

    f1mktsol, the easy way is to insert the shortcode in the page/post and not in the template file.

    If that is not possible, you will have to hack the lib/attachment.php and do something along the lines of
    substitute (2 times in the script)
    has_shortcode( 'wpuf_addpost' )
    with
    $post->ID == 11111 || has_shortcode( 'wpuf_addpost' )
    and add
    global $post;
    in a new line under
    function scripts() {

    Replace 11111 in the code above with your post/page ID.
    This code is not tested. Hope it helps!

    Hi Tareq,
    I am using wp-user-frontend plugin on my website.Its upload featured image and additional image code is working fine on chrome,mozilla,rockmelt browsers but not functioning properly in IE and Safari browsers So please help me solve this issue.

    applegateian

    @applegateian

    Hi a.blok

    I have tried what you suggested, didn’t work unfortunately.

    Any ideas?

    function scripts() {
            if ( $post->ID == 286 || has_shortcode( 'wpuf_addpost' )  || has_shortcode( 'wpuf_edit' ) || has_shortcode( 'wpuf_dashboard' ) ) {
    
                $max_file_size = intval( wpuf_get_option( 'attachment_max_size' ) ) * 1024;
                $max_upload = intval( wpuf_get_option( 'attachment_num' ) );
                $attachment_enabled = wpuf_get_option( 'allow_attachment' );
    			global $post;
                wp_enqueue_script( 'jquery' );
                if ( $post->ID == 286 || has_shortcode( 'wpuf_addpost' ) || has_shortcode( 'wpuf_edit' ) ) {
                    wp_enqueue_script( 'plupload-handlers' );
                }

    Hi applegateian,
    there is an error in your script:
    global $post;
    must be the first line after
    function scripts() {

    Just move the line of code and it should work.

    applegateian

    @applegateian

    Ok I moved that, cleared cache, still the same – code for the whole section is here – thanks:

    function scripts() {
        		global $post;
            if ( $post->ID == 286 || has_shortcode( 'wpuf_addpost' )  || has_shortcode( 'wpuf_edit' ) || has_shortcode( 'wpuf_dashboard' ) ) {
                $max_file_size = intval( wpuf_get_option( 'attachment_max_size' ) ) * 1024;
                $max_upload = intval( wpuf_get_option( 'attachment_num' ) );
                $attachment_enabled = wpuf_get_option( 'allow_attachment' );
                wp_enqueue_script( 'jquery' );
                if ( $post->ID == 286 || has_shortcode( 'wpuf_addpost' ) || has_shortcode( 'wpuf_edit' ) ) {
                    wp_enqueue_script( 'plupload-handlers' );
                }
                wp_enqueue_script( 'jquery-ui-sortable' );
                wp_enqueue_script( 'wpuf_attachment', plugins_url( 'js/attachment.js', dirname( __FILE__ ) ), array('jquery') );
    
                wp_localize_script( 'wpuf_attachment', 'wpuf_attachment', array(
                    'nonce' => wp_create_nonce( 'wpuf_attachment' ),
                    'number' => $max_upload,
                    'attachment_enabled' => ($attachment_enabled == 'yes') ? true : false,
                    'plupload' => array(
                        'runtimes' => 'html5,silverlight,flash,html4',
                        'browse_button' => 'wpuf-attachment-upload-pickfiles',
                        'container' => 'wpuf-attachment-upload-container',
                        'file_data_name' => 'wpuf_attachment_file',
                        'max_file_size' => $max_file_size . 'b',
                        'url' => admin_url( 'admin-ajax.php' ) . '?action=wpuf_attach_upload&nonce=' . wp_create_nonce( 'wpuf_audio_track' ),
                        'flash_swf_url' => includes_url( 'js/plupload/plupload.flash.swf' ),
                        'silverlight_xap_url' => includes_url( 'js/plupload/plupload.silverlight.xap' ),
                        'filters' => array(array('title' => __( 'Allowed Files' ), 'extensions' => '*')),
                        'multipart' => true,
                        'urlstream_upload' => true,
                    )

    + 1
    I have the same issue as applegateian.
    The “Add another” button works in all browsers except for IE.

    Any ideas?

    Resolved my IE specific issue by commenting out attachment.php’s calls to use the silverlight flavor of plupload, see here.

Viewing 13 replies - 1 through 13 (of 13 total)
  • The topic ‘[Plugin: WP User Frontend] Image attachment not working error in JS file’ is closed to new replies.
Skip to toolbar