Quel est le plugin ou le script de téléchargement ajax le plus simple à utiliser avec wordpress?
-
-
J'aiessayé l'uploader defichiers valumsmaisn'apasfonctionné,et j'ai suivi cetutoriel http://www.krishnakantsharma.com/2012/01/image-uploads-on-wordpress-admin-screens-using-jquery-and-new-plupload/çamarchemaisje ne comprendspas lefichierjs qu'il a écrit.I tried valums file uploader but didn't work, and followed this tutorial http://www.krishnakantsharma.com/2012/01/image-uploads-on-wordpress-admin-screens-using-jquery-and-new-plupload/ it works but I don't understand the js file that he wrote.
- 0
- 2012-04-26
- Pierre
-
2 réponses
- votes
-
- 2012-04-26
J'ai utilisé letéléchargeurnatif avec d'excellents résultats. Essayez d'ajouter cetextrait de JS:
jQuery('#upload_image_button').click(function() { formfield = jQuery('#fwpPhoto').attr('name'); tb_show('', 'media-upload.php?type=image&TB_iframe=true'); return false; }); window.send_to_editor = function(html) { imgurl = jQuery('img',html).attr('src'); jQuery('#fwpPhoto').val(imgurl); tb_remove(); }
Ensuite,dans votre HTML:
<input id="fwpPhoto" name="facultyPhoto" value=""> <input id="upload_image_button" type="button" value="Upload Image">
Pourplusieurstéléverseurs
<input id="facultyPhoto-1" name="facultyPhoto-1" value="" class="fwpPhoto"> <input id="upload_image_button-1" class="uploadButton" type="button" value="Upload Image"> <input id="facultyPhoto-2" name="facultyPhoto-2" value="" class="fwpPhoto"> <input id="upload_image_button-2" class="uploadButton" type="button" value="Upload Image"> <input id="facultyPhoto-3" name="facultyPhoto-3" value="" class="fwpPhoto"> <input id="upload_image_button-3" class="uploadButton" type="button" value="Upload Image"> <input id="facultyPhoto-4" name="facultyPhoto-4" value="" class="fwpPhoto"> <input id="upload_image_button-4" class="uploadButton" type="button" value="Upload Image"> <script type="text/javascript"> jQuery(document).ready(function($){ var target = ''; $('.fwpPhoto').each(function(index) { var field = index + 1; //because index starts at 0 jQuery('#upload_image_button-'+field).click(function() { formfield = jQuery('#facultyPhoto-'+field).attr('name'); target = '#'+formfield; tb_show('', 'media-upload.php? type=image&TB_iframe=true'); return false; }); }); window.send_to_editor = function(html) { imgurl = jQuery('img',html).attr('src'); jQuery(target).val(imgurl); tb_remove(); } }); </script>
I have used the native uploader with great results. Try adding this snippet of JS:
jQuery('#upload_image_button').click(function() { formfield = jQuery('#fwpPhoto').attr('name'); tb_show('', 'media-upload.php?type=image&TB_iframe=true'); return false; }); window.send_to_editor = function(html) { imgurl = jQuery('img',html).attr('src'); jQuery('#fwpPhoto').val(imgurl); tb_remove(); }
Then, in your HTML:
<input id="fwpPhoto" name="facultyPhoto" value=""> <input id="upload_image_button" type="button" value="Upload Image">
For Multiple Uploaders
<input id="facultyPhoto-1" name="facultyPhoto-1" value="" class="fwpPhoto"> <input id="upload_image_button-1" class="uploadButton" type="button" value="Upload Image"> <input id="facultyPhoto-2" name="facultyPhoto-2" value="" class="fwpPhoto"> <input id="upload_image_button-2" class="uploadButton" type="button" value="Upload Image"> <input id="facultyPhoto-3" name="facultyPhoto-3" value="" class="fwpPhoto"> <input id="upload_image_button-3" class="uploadButton" type="button" value="Upload Image"> <input id="facultyPhoto-4" name="facultyPhoto-4" value="" class="fwpPhoto"> <input id="upload_image_button-4" class="uploadButton" type="button" value="Upload Image"> <script type="text/javascript"> jQuery(document).ready(function($){ var target = ''; $('.fwpPhoto').each(function(index) { var field = index + 1; //because index starts at 0 jQuery('#upload_image_button-'+field).click(function() { formfield = jQuery('#facultyPhoto-'+field).attr('name'); target = '#'+formfield; tb_show('', 'media-upload.php? type=image&TB_iframe=true'); return false; }); }); window.send_to_editor = function(html) { imgurl = jQuery('img',html).attr('src'); jQuery(target).val(imgurl); tb_remove(); } }); </script>
-
mercimaisj'aiessayé cetteméthode avant,et enfait c'estmonproblème avec cetteméthodeet d'autres scripts carj'aibesoin deplusieurs uploaders surmapage,et jene suispasexpérimenté avecjavascript doncje ne saispas comment lefaire.thank you but I tried this method before, and actually that's my problem with this method and other scripts because I need multiple uploaders on my page, and I'm not experienced with javascript so I don't know how to do it.
- 0
- 2012-04-26
- Pierre
-
De combien detéléverseursparlez-vous?Cela variera-t-il?How many uploaders are you talking about? Will it vary?
- 0
- 2012-04-26
- Aaron Wagner
-
ouij'essaye de le rendre aussi dynamique quepossible.yes I'm trying to make it as dynamic as possible.
- 0
- 2012-04-26
- Pierre
-
J'aimis àjourma réponse.J'aitesté celaet celafonctionnetrèsbien.Merci d'avoirposé cette question,carje voulaisen faitfaire quelque chose comme ça dansmespropresthèmes.I updated my answer. I have tested this, and it works great. Thanks for asking this question, because I have actually been meaning to do something like this in my own themes.
- 0
- 2012-04-26
- Aaron Wagner
-
- 2012-04-26
avez-vousessayé d'utiliser lepluginjqueryform http://jquery.malsup.com/form/
Ilest égalementincluspar défaut dans l'administration de wordpress.
have you tried using jquery form plugin http://jquery.malsup.com/form/
It is also included by default in wordpress admin.
-
merci,il semble qu'iln'apasbesoin de compétencesen codage,je vais l'essayeret voir si celafonctionne.thank you, it seems that it doesn't need coding skills, I'll try it and see if it works.
- 0
- 2012-04-26
- Pierre
J'essaie d'utiliser letéléchargement d'image dans lapage d'options demonthèmeet jen'aipasencoretrouvé de script detéléchargement ajax simple avec denombreuxtutoriels ou unebonne documentation,je veuxjuste un script simpleet direct,je modifie simplement le chemin dufichieretquelques autres choses,et bien sûr celafonctionne avec denombreux uploaders sur lapage.
J'aiessayépluploadmais c'est compliquépourmoi carje ne connais rien aujavascript,juste unpeu de compréhension dejQuery.
Alors,y a-t-il des uploaders ajax simples avec unbontutoriel à ce sujet?