Tagged: 

Viewing 15 reply threads
  • Author
    Posts
    • #1013
      atomworks
      Member

      I’m sure in older versions of Piklist I’ve put an uploader on a widget, but I may well be imagining it.

      On this latest beta I can’t seem to upload media through a widget, I get a similar js error the the one that was encountered with the ones that were throwing a spanner in the works on images on posts. Is it meant to work or has this not been looked at yet? Any clues where I might look to deal with this? I’ll do some digging as per usual but if you’ve got a clue for me that’d be great!

    • #1014
      Steve
      Keymaster

      Try the latest Beta. Released today >

    • #1022
      atomworks
      Member

      Still having problems with widget image uploaders (though the post image meta seems to have the kinks ironed out for me).

      With the widget uploader, when I press the button I get the javascript error come up in the console:

      Uncaught TypeError: Cannot read property 'frames' of undefined - piklist.js?ver=0.8.0b4:804

      I’m using the following code to define the field in the [widgetname]-forms.php file:

        piklist('field', array(
          'type' => 'file',
          'field' => 'upload_media',
          'label' => 'Add File(s)',
          'description' => 'This is the uploader seen in the admin by default.',
          'options' => array(
      		'title' => 'Add File(s)', 
      		'button' => 'Add'
          )
        ));
    • #1023
      atomworks
      Member

      Hi guys, back in the usual fashion I’ve found the problem and got a solution. It’s a simple one really though my implementation most likely needs some actual polishing as it covers the whole admin and not just the area it needs (which may cause issues elsewhere?). I’m sure you know where it’ll need to live in Piklist!

      Basically it’s just missing: wp_enqueue_media();

      That’s responsible for filling out the vital part to the javascript object that the media uploader uses.

      So as a temporary fix I’ve just put this in my functions.php:

      function add_media_support(){ wp_enqueue_media(); }
      add_action( 'admin_init', 'add_media_support' );

      There are a couple of problems that spring up from there but nothing major. Firstly, it seems to make an extra empty media item each time I do it. If I leave it in, it’s not an issue; if I delete it, it’s not an issue; either way it’s a minor annoyance then a show stopper.

      The second problem is that you can’t just do $setting[‘field_name’] and have your link as it only outputs the attachment ID. I’m sure this is something you’ll look to clear up though for anyone who might stumble across this scratching their head you can pull the information easily with the following.

      <?php $image = wp_get_attachment_image_src( $settings['field_name'], 'single-post-thumbnail' ); ?>
      <img src="<?php echo $image[0]; ?>" alt="">

      Obviously the above is for images only but can be similarly adapted for files to the best of my knowledge

      Hope that all helps! 🙂

    • #1025
      Steve
      Keymaster

      @atomworks– Thanks for the bug and solution. We’ll look for a better way to load wp_enqueue_media(), then we currently have.

    • #1026
      chrisben
      Member

      Thanks for this fix atomworks, though it only seem to work when editing an existing post: there’s still a javascript issue preventing us from uploading an image when editing a new post.

    • #1027
      atomworks
      Member

      This fix is in regards to widgets rather then posts and from my quick checks didn’t affect anything else (though that’s not to say I missed it). Did you mean to post that on the similar thread I had going on post media upload problems?

      The only I had similar to what you’ve mentioned seems to have been fixed up in the latest beta version, have you tried it?

    • #1028
      chrisben
      Member

      My issue, even with latest beta 4, is with custom image upload on a custom post type edit : I get javascript errors preventing me from uploading the image (clicking on the button does nothing).
      To reproduce: piklist demos, try to set a feature image on “add new piklist demo”.

      The fix you suggested here (wp_enqueue_media) fixes that issue, though only when editing an existing CPT, not when creating a new post.

      Sorry I got confused between the two issues here, but they seem somehow linked (same javascript errors related to media stuff).

    • #1029
      Steve
      Keymaster

      @chrisben– Make sure your cache is clear, or try another browser. This should be fixed in beta 4.

    • #1030
      chrisben
      Member

      Tried with both FF and Chrome, nuked their cache and the extension in my wordpress shows version number “0.8.0b4”, I can still reproduce issue with Piklist Demos.

    • #1035
      chrisben
      Member

      Anybody else can reproduce the js issue with the “add new Piklist Demo” > “set Featured Image(s)” button (“Cannot read property ‘id’ of undefined”) in beta 4 ?

    • #1036
      atomworks
      Member

      Hi,

      The micro-fix I mentioned earlier does seem to break the built in functionality for featured images, and could be causing issues elsewhere. Not sure if that may be something that’s throwing a spanner in the works… I’ve tweaked my fix and it seems to have me on track for now. I’ll report back in if anything else crops up!

      
      /** Piklist widget uploader requirement (fix) **/
      	
      	function add_media_support(){ 
      		if(is_admin() && last_url_segment() == 'widgets.php'){
      			wp_enqueue_media(); 
      		}
      	}
      	add_action( 'admin_init', 'add_media_support' );
      
      /*
      **	Last URL Segment Function
      */
      		
      	function last_url_segment(){
      		
      		$uri = $_SERVER['REQUEST_URI'];
      		$no_var = explode('?',$uri);
      		$pieces = array_filter(explode("/", $no_var[0]));
      		
      		return end($pieces);
      		
      	} 
      
    • #1037
      Steve
      Keymaster

      We’re releasing a fix today. Will post here when it’s up on Trunk.

    • #1041
      Steve
      Keymaster
    • #1044
      chrisben
      Member

      Guys, this is it! — at least for the issue I reported here, I haven’t tried the main widget one —

      Thanks for your work!

    • #1047
      Steve
      Keymaster

      Awesome! Closing ticket.

Viewing 15 reply threads
  • You must be logged in to reply to this topic.