Tagged: upload
- This topic has 15 replies, 3 voices, and was last updated 8 years, 5 months ago by
Steve.
-
AuthorPosts
-
-
August 23, 2013 at 1:07 pm #1013
atomworksMemberI’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!
-
August 23, 2013 at 1:31 pm #1014
SteveKeymasterTry the latest Beta. Released today >
-
August 24, 2013 at 8:59 am #1022
atomworksMemberStill 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:804I’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' ) )); -
August 24, 2013 at 10:43 am #1023
atomworksMemberHi 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! 🙂
-
August 25, 2013 at 12:25 am #1025
SteveKeymaster@atomworks– Thanks for the bug and solution. We’ll look for a better way to load
wp_enqueue_media(), then we currently have. -
August 26, 2013 at 7:51 am #1026
chrisbenMemberThanks 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.
-
August 26, 2013 at 8:00 am #1027
atomworksMemberThis 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?
-
August 26, 2013 at 8:21 am #1028
chrisbenMemberMy 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).
-
August 26, 2013 at 10:06 am #1029
-
August 26, 2013 at 11:00 am #1030
chrisbenMemberTried 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.
-
August 29, 2013 at 4:03 am #1035
chrisbenMemberAnybody 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 ?
-
August 29, 2013 at 9:49 am #1036
atomworksMemberHi,
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); } -
August 29, 2013 at 10:02 am #1037
SteveKeymasterWe’re releasing a fix today. Will post here when it’s up on Trunk.
-
August 29, 2013 at 12:19 pm #1041
SteveKeymaster -
August 30, 2013 at 10:13 am #1044
chrisbenMemberGuys, this is it! — at least for the issue I reported here, I haven’t tried the main widget one —
Thanks for your work!
-
August 30, 2013 at 2:21 pm #1047
SteveKeymasterAwesome! Closing ticket.
-
-
AuthorPosts
- You must be logged in to reply to this topic.