admin管理员组文章数量:1313822
I have created a couple of back end pages for a client using a very basic database, the client is wanting to add an image url to the database but using the built in image selector/uploader, I have tried going through the wordpress documentation but have yet to find an example.
I was hoping there was an easy way to do it with wp_editor(); but i can't seem to find an exact way to just have the media button and a text input.
Hopefully someone can shed some light for me or point me in the right direction.
Kind Regards,
Adam
EDIT: this is how my code looks so you can see what i am doing.
$row = $wpdb->get_results( "SELECT * FROM wp_events WHERE id = $edit_id" );
if(!$row){
echo 'No Entry with ID '.$edit_id.' please choose another or add a new event.'; goto new_form;
}
foreach ( $row as $row )
{
$right_details = $row->right_details;
$left_details = $row->left_details;
if (!$_POST['submitEditEvent']) {
echo '<form method="POST" action="?page=upcoming_events&id='.$edit_id.'" id="events">
<label style="font-weight:bold">Event Name: </label><input type="text" name="name" value="'.$row->name.'" /><br />
<label style="font-weight:bold">Event Description: </label>';
wp_editor($left_details,"left_details", array('textarea_rows'=>12, 'editor_class'=>'left_details_class'));
echo '<br />
<label style="font-weight:bold">Location: </label><input type="text" name="location" value="'.$row->location.'"/><br />
<label style="font-weight:bold">Price: </label><input type="text" name="price" value="'.$row->price.'"/><span>Please include £<br />
<label style="font-weight:bold">Ticket Link: </label><input type="text" name="ticket" /> <input type="checkbox" name="ticket_door" value="1"';
if($row->ticket_door == 1) { echo 'checked'; }
echo '><span style="font-weight:bold">If the event is pay at the door ticket this checkbox and leave the text box empty.</span><br /><br />
<label style="font-weight:bold">Start Date: </label><input type="date" name="start_date" value="'.$row->start_date.'" /><span style="font-weight:bold">Leave Blank for Coming Soon</span><br />
<label style="font-weight:bold">End Date: </label><input type="date" name="end_date" value="'.$row->end_date.'"/><span style="font-weight:bold">Leave Blank for Coming Soon</span><br />
<label style="font-weight:bold">Start Time: </label><input type="time" name="time_start" value="'.$row->time_start.'"/><br />
<label style="font-weight:bold">End Time: </label><input type="time" name="time_end" value="'.$row->time_end.'"/><br />
<label style="font-weight:bold">Google Map Link: </label><input type="text" name="mapurl" value="'.$row->mapurl.'"/> <input type="checkbox" name="pilotbar" value="1"';
if($row->pilotbar == 1) { echo 'checked'; }
echo '><span style="font-weight:bold">If the event is taking place at the pilot bar/pilot field check this box and leave the text box empty.</span><br /><br />
<label style="font-weight:bold">Important Information: </label>';
wp_editor($right_details,"right_details", array('textarea_rows'=>12, 'editor_class'=>'right_details_class'));
echo '<br />
<label style="font-weight:bold">Image: </label>';
{HERE IS WHERE I WANT THE IMAGE SELECTOR}
echo '<input type="submit" name="submitEditEvent" value="submit" class="button-primary" style=" margin-left: 25%; width: 50%;" /></form>';
}
}
I just want the basic wordpress image selector and uploader which loads images into the standard uploads folder, the result would sent the direct image url to the database so when its called on the page it will be like this
echo '<img src="'.$row->image.'"></img>';
本文标签: plugin developmentAdding the image selectoruploader to an admin back page
版权声明:本文标题:plugin development - Adding the image selectoruploader to an admin back page 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741875367a2402429.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论