The article is in Series WordPress installation FAQ
answer the question 3 week July/2015 of readers on how to Upload files in WordPress admin.
Q: sorry to bother you, don't fall in Prince's success has a WordPress website, but I want to add the script media in wordpress admin and create file upload.js anymore, you can just please themselves? Sincere thanks!
To answer the question:
hey, you read,
1. To add media in the wordpress admin script you insert this paragraph into the admin file:
Crayon Syntax Highlighter v 2.7.1
-
add_action (' admin_enqueue_scripts ', ' tp_admin_enqueue_styles ');
add_action (' admin_enqueue_scripts ', ' tp_admin_enqueue_scripts ');
function tp_admin_enqueue_styles () {
wp_enqueue_style (' thickbox '); [ &]}
function tp_admin_enqueue_scripts () {
wp_enqueue_media ()//this is very important, don't have it is hand bouquet
http://Codex.WordPress.org/function_reference/wp_enqueue_script (' tp-upload-script ', ' http://duong_dan_den_folder/upload.js ', array (' jquery '), ' 1.0 ', true); [ &]}
12345678910111213-add_action (' admin_enqueue_scripts ', ' tp_admin_enqueue_styles '); & nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp; add_action (' admin_enqueue_scripts ', ' tp_admin_enqueue_scripts '); & nbsp; function tp_admin_enqueue_styles () {& nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp; wp_enqueue _ style (' thickbox ');} & nbsp; function tp_admin_enqueue_scripts () {wp_enqueue_media ()//this is very important, don't have it is the taywp_enqueue_script bundle (' tp-upload-script ', ' http://duong_dan_den_folder/upload.js ', array (' jquery '), ' 1.0 ', true);}
[Format Time: 0.0031 seconds]
2. Create upload.js file inside yourself there will be js snippets like this:
name of the upload button id is: #tp_upload. This ID may be of button, input, & lt; a & gt; whichever you want.
Crayon Syntax Highlighter v 2.7.1
-
(function ($) {
"use strict"; [ &] var custom_uploader;
$ (' #tp_upload '). click (function (e) {
var img_input = $ (' #id_cua_the_input_muon_lay_link_image '); [ &] e. preventDefault ();
//If the uploader object has already been created, reopen the dialog
if (custom_uploader) {
custom_uploader. open [(); &] return;
}
//Extend the wp media object
custom_uploader = wp. media. frames. file_frame = wp. media ({
title: ' Choose Image ',
button: {
text: ' Choose Image '
},
multiple: true
});
//When a file is selected, grab the URL and set it as the text field's value
custom_uploader. on (' select ', function () {
var selection = custom_uploader. state () get (' selection '); [ &] selection.map (function (attachment) {
attachment = attachment. toJSON (); [ &] var url = attachment.url;
img_input.val (url)//this is to get the url you've just put up the tag input
});
});
//Open the uploader dialog
custom_uploader. open ();
return false;
});
}) (jQuery);
12345678910111213141516171819202122232425262728293031323334353637383940
-(function ($) {& nbsp; & nbsp; & nbsp; & nbsp; " use strict "& nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp;; var custom_uploader; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp; $ (' #tp_upload '). click (function (e) {& nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp; var img_input = $ (' #id_cua_the_input_muon_lay_link_image '); & nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp; e. preventDefault (); & nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp;//If the uploader object has already been created, reopen the dialog & nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp; if (custom_uploader) {& nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp; custom_uploader. open (); & nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp; return; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp;} & nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp;//Extend the wp media & nbsp; object. & nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp; custom_uploader = wp. media. frames. file_frame = wp. media & nbsp & nbsp; ({& nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp; title; : ' Choose Image & nbsp & nbsp;, '; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp; button: {& nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp; text: ' Choose & nbsp & nbsp; Image'; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp}; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp;: true multiple & nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp;}); & nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp;//When a file is selected, grab the URL and set it as the text & nbsp; & nbsp value field's; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp; custom_uploader. on (' select ', function () {& nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp; var selection = custom_uploader. state () get (' selection '); & nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp; selection.map (function (attachment) {& nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp; attachment = attachment. & nbsp; toJSON; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp; var url = & nbsp; & nbsp; attachment.url; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp; img_input.val (url)//this is to get the url you just put in the input tag & nbsp ups; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp;}); & nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp;}); & nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp;//Open the uploader dialog & nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp; custom_uploader. open (); & nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp; return false; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp; });}) (jQuery);
[Format Time: 0.0084 seconds]
You refer to. Cordially!
You can review the instructions to install WordPress in your case study to learn how to configure and set up correctly. If you have read the other comments about how to Upload files in WordPress admin please leave comments below to help you read knows how to handle this situation. Thank you for visiting the Royal Blog reading Passage.
In addition, you can refer to a number of posts or about errors in WordPress Admin:
Asked how to Upload files in WordPress admin?
Asked how this page in WordPress Admin Panel does not display properly?
Ask errors when logging into Admin after upgrading WordPress?
Asked when logging into Admin WordPress error 404?
Question sorry can not login to the WordPress Admin?
& nbsp;
photo: Asked how to Upload files in WordPress admin?
Tag: cach upload file in the wordpress admin, WordPress Admin account creation instructions, limiting the local attack in WordPress, custom WordPress Admin Guide, how to backup wordpress website, install wordpress error, error diffusion, common errors, bugs or encounter, how to handle errors, resolve the error, fix the error, situation, Vietnamese wordpress FAQ, wordpress, loi, loi Beach thuong gap, loi or gap, cach xu ly loi, Chris l loi, loi, phuc loi khac huong tinh, error install wordpress, loi cai dat wp, localhost, hosting, server, vps, may chu, viet, hostinger Payam, wordpress wordpress Multisite, wordpress plugin, wp instal operated, themes, free, download, share, documentation, faq, wordpress, and autumn dap hoi thuat wordpress , thu thuat thu thuat web, seo
Vietnamese WordPress» WordPress Hoc» using WordPress» WordPress FAQ
wordpress-mobile-app-plugin
Nhận xét
Đăng nhận xét