Support » Requests and Feedback » [Plugin: Custom Field Template] Preview image for textarea

[Plugin: Custom Field Template] Preview image for textarea

  • Hi,

    I’ve been playing with the Custom Field Template and what I’ve trying to do is to use a textarea with mediaButton to insert an image into a custom field. It kind of works; but when the image is displayed (on click in the case below) the code in the text area disappears. I’ve tried to write it back in this case.

    type = 	textarea
    mediaButton = true
    label = Photo
    rows = 5
    cols = 25
    onclick= var image = this.value; this.parentNode.parentNode.innerHTML +=image; this.innerHTML = image

    I’ve also noticed that when this code is run the textarea becomes unusable. I wonder if it is possible? Otherwise I’ll stick with the complete tinyMCE view.

Viewing 1 replies (of 1 total)
  • Found out it was better to use a select drop down. For anyone looking for something similar see below:

    type = select
    code = 2
    after = <div></div>
    multipleButton = true
    onchange = var start = (this.value).indexOf('<'); this.parentNode.getElementsByTagName('div')[0].innerHTML = (this.value).slice(start);

    code 2:

    global $wpdb;
    $values = array();
    $attachments = $wpdb->get_results('SELECT * FROM ' . $wpdb->prefix . 'posts WHERE post_type="attachment"');
    foreach ($attachments as $attachment) {
        $str = $attachment->post_title;
        $str .= '[' . $attachment->ID . ']';
    	$img = wp_get_attachment_image($attachment->ID, $size='thumbnail', $icon = false);
         $str .=  $img;
    $values[] = $str;

    The only issue I get now is the multiple button does not save multiple entries 🙁

Viewing 1 replies (of 1 total)
  • The topic ‘[Plugin: Custom Field Template] Preview image for textarea’ is closed to new replies.