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