WordPress.org

Ready to get started?Download WordPress

Forums

WP User Frontend
Image attachment not working error in JS file (14 posts)

  1. argon2000
    Member
    Posted 2 years ago #

    Attachment isn't working in version 1.0 anymore with 3.4

    Timestamp: 17/06/12 8:44:41 AM
    Error: $("#wpuf-attachment-upload-filelist ul.wpuf-attachment-list").sortable is not a function
    Line: 11

    http://wordpress.org/extend/plugins/wp-user-frontend/

  2. Tareq Hasan
    Member
    Plugin Author

    Posted 2 years ago #

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

  3. argon2000
    Member
    Posted 2 years ago #

    I just checked yes I have that

  4. argon2000
    Member
    Posted 2 years ago #

    I comment the sortable function out it seem to cause issues

  5. applegateian
    Member
    Posted 1 year ago #

    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?

  6. a.blok
    Member
    Posted 1 year ago #

    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!

  7. f1mktsol
    Member
    Posted 1 year ago #

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

  8. a.blok
    Member
    Posted 1 year ago #

    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!

  9. Deeju
    Member
    Posted 1 year ago #

    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.

  10. applegateian
    Member
    Posted 1 year ago #

    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' );
                }
  11. a.blok
    Member
    Posted 1 year ago #

    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.

  12. applegateian
    Member
    Posted 1 year ago #

    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,
                    )
  13. Runamok81
    Member
    Posted 1 year ago #

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

    Any ideas?

  14. Runamok81
    Member
    Posted 1 year ago #

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

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic