当前位置: 首页>>代码示例>>PHP>>正文


PHP _wp_post_thumbnail_html函数代码示例

本文整理汇总了PHP中_wp_post_thumbnail_html函数的典型用法代码示例。如果您正苦于以下问题:PHP _wp_post_thumbnail_html函数的具体用法?PHP _wp_post_thumbnail_html怎么用?PHP _wp_post_thumbnail_html使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了_wp_post_thumbnail_html函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: jopfre_post_thumbnail_meta_box

function jopfre_post_thumbnail_meta_box($post)
{
    //from wp core post_thumbnail_meta_box()
    $thumbnail_id = get_post_meta($post->ID, '_thumbnail_id', true);
    echo _wp_post_thumbnail_html($thumbnail_id, $post->ID);
    //use nonce for verification
    wp_nonce_field('jopfre_save_featured_image_position', 'jopfre_featured_image_position_nonce');
    // get current value
    $dropdown_value = get_post_meta($post->ID, 'jopfre_featured_image_position', true);
    ?>
  <p><strong>Position</strong></p>
  <select name="jopfre_featured_image_position" id="jopfre_featured_image_position">
    <option value="center" <?php 
    if ($dropdown_value == 'center') {
        echo 'selected';
    }
    ?>
>center</option>
    <option value="top" <?php 
    if ($dropdown_value == 'top') {
        echo 'selected';
    }
    ?>
>top</option>
    <option value="bottom" <?php 
    if ($dropdown_value == 'bottom') {
        echo 'selected';
    }
    ?>
>bottom</option>
  </select>
<?php 
}
开发者ID:jopfre,项目名称:wordpress-featured-image-position-selector-plugin,代码行数:33,代码来源:jopfre-featured-image-position-selector.php

示例2: ajax

 public function ajax()
 {
     $post = array('id' => $_POST['id'], 'fvp_nonce' => isset($_POST['fvp_nonce']) ? $_POST['fvp_nonce'] : '', 'fvp_set_featimg' => isset($_POST['fvp_set_featimg']) ? $_POST['fvp_set_featimg'] : '', 'fvp_video' => isset($_POST['fvp_video']) ? $_POST['fvp_video'] : '', 'fvp_sec' => isset($_POST['fvp_sec']) ? $_POST['fvp_sec'] : '');
     $meta = $this->save($post);
     $img = _wp_post_thumbnail_html(get_post_thumbnail_id($post['id']), $post['id']);
     if (has_post_video($post['id'])) {
         $video = get_the_post_video($post['id'], array(256, 144));
         echo json_encode(array('typ' => 'updated', 'valid' => $meta['valid'], 'video' => $video, 'img' => $img, 'prov' => $meta['prov'], 'id' => $meta['id']));
     } else {
         echo json_encode(array('typ' => 'removed', 'valid' => $meta['valid'], 'img' => $img));
     }
     die;
 }
开发者ID:bensethro,项目名称:runcyb,代码行数:13,代码来源:backend.php

示例3: get_post_meta

    ?>
</p>
		</div>
		<?php 
}
?>

		<?php 
if (post_type_supports('directory_listing', 'thumbnail') && current_theme_supports('post-thumbnails')) {
    ?>
		<div class="editfield">
			<div id="postimagediv">
				<div class="inside">
					<?php 
    $thumbnail_id = get_post_meta($post_ID, '_thumbnail_id', true);
    echo _wp_post_thumbnail_html($thumbnail_id, $post_ID);
    ?>
				</div>
			</div>
		</div>
		<?php 
}
?>

		<?php 
if (post_type_supports('directory_listing', 'editor')) {
    ?>
		<div>
			<label for="listingcontent"><?php 
    _e('Content', $this->text_domain);
    ?>
开发者ID:httvncoder,项目名称:151722441,代码行数:31,代码来源:page-update-listing.php

示例4: wp_ajax_set_post_thumbnail

function wp_ajax_set_post_thumbnail()
{
    $post_ID = intval($_POST['post_id']);
    if (!current_user_can('edit_post', $post_ID)) {
        wp_die(-1);
    }
    $thumbnail_id = intval($_POST['thumbnail_id']);
    check_ajax_referer("set_post_thumbnail-{$post_ID}");
    if ($thumbnail_id == '-1') {
        if (delete_post_thumbnail($post_ID)) {
            wp_die(_wp_post_thumbnail_html(null, $post_ID));
        } else {
            wp_die(0);
        }
    }
    if (set_post_thumbnail($post_ID, $thumbnail_id)) {
        wp_die(_wp_post_thumbnail_html($thumbnail_id, $post_ID));
    }
    wp_die(0);
}
开发者ID:par-orillonsoft,项目名称:Wishmagnet,代码行数:20,代码来源:ajax-actions.php

示例5: wp_restore_image

                break;
            case 'restore':
                $msg = wp_restore_image($attachment_id);
                break;
        }
        wp_image_editor($attachment_id, $msg);
        die;
        break;
    case 'set-post-thumbnail':
        $post_id = intval($_POST['post_id']);
        if (!current_user_can('edit_post', $post_id)) {
            die('-1');
        }
        $thumbnail_id = intval($_POST['thumbnail_id']);
        if ($thumbnail_id == '-1') {
            delete_post_meta($post_id, '_thumbnail_id');
            die(_wp_post_thumbnail_html());
        }
        if ($thumbnail_id && get_post($thumbnail_id)) {
            $thumbnail_html = wp_get_attachment_image($thumbnail_id, 'thumbnail');
            if (!empty($thumbnail_html)) {
                update_post_meta($post_id, '_thumbnail_id', $thumbnail_id);
                die(_wp_post_thumbnail_html($thumbnail_id));
            }
        }
        die('0');
    default:
        do_action('wp_ajax_' . $_POST['action']);
        die('0');
        break;
}
开发者ID:nagyist,项目名称:laura-wordpress,代码行数:31,代码来源:admin-ajax.php

示例6: set_featured_image

 /**
  * Set featured image from $url
  */
 public function set_featured_image()
 {
     require_once ABSPATH . 'wp-admin/includes/media.php';
     require_once ABSPATH . 'wp-admin/includes/file.php';
     require_once ABSPATH . 'wp-admin/includes/image.php';
     require_once ABSPATH . 'wp-includes/pluggable.php';
     $url = sanitize_text_field($_POST['url']);
     $post_id = sanitize_text_field($_POST['postID']);
     $desc = sanitize_text_field($_POST['description']);
     // Sideload image, returns image src
     $image_id = $this->sideload_featured_image($url, $post_id, $desc);
     if (is_wp_error($image_id)) {
         wp_die(0);
     } else {
         // Set featured image
         set_post_thumbnail($post_id, $image_id);
         $return = _wp_post_thumbnail_html($image_id, $post_id);
         wp_die($return);
     }
 }
开发者ID:gopinathshiva,项目名称:wordpress-vip-plugins,代码行数:23,代码来源:ndn_plugin_admin.php

示例7: cp_delete_ad_thumbnail

/**
 * Deletes the thumbnail pic on the WP admin post.
 *
 * @deprecated 3.4
 *
 * @param int $post_id
 *
 * @return void
 */
function cp_delete_ad_thumbnail($post_id)
{
    _deprecated_function(__FUNCTION__, '3.4');
    delete_post_meta($post_id, '_thumbnail_id');
    die(_wp_post_thumbnail_html());
}
开发者ID:kalushta,项目名称:darom,代码行数:15,代码来源:deprecated.php

示例8: ajax_zemanta_set_featured_image

 /**
  * ajax_zemanta_set_featured_image
  *
  * Download and set featured image by URL
  * @require WordPress 3.1+
  */
 public function ajax_zemanta_set_featured_image()
 {
     global $post_ID;
     if (!isset($this->supported_features['featured_image'])) {
         $this->ajax_error(new WP_Error(4, __('Featured image feature is not supported on current platform.', 'zemanta')));
     }
     $args = wp_parse_args($_REQUEST, array('post_id' => 0, 'image_url' => ''));
     extract($args);
     $post_id = (int) $post_id;
     if (!empty($image_url) && $post_id) {
         $http_response = wp_remote_get($image_url, array('timeout' => 10));
         if (!is_wp_error($http_response)) {
             $data = wp_remote_retrieve_body($http_response);
             // throw error if there no data
             if (empty($data)) {
                 $this->ajax_error(new WP_Error(5, __('Featured image has invalid data.', 'zemanta')));
             }
             $upload = wp_upload_bits(basename($image_url), null, $data);
             if (!is_wp_error($upload) && !$upload['error']) {
                 $filename = $upload['file'];
                 $wp_filetype = wp_check_filetype(basename($filename), null);
                 $attachment = array('post_mime_type' => $wp_filetype['type'], 'post_title' => preg_replace('/\\.[^.]+$/', '', basename($filename)), 'post_content' => '', 'post_status' => 'inherit');
                 $attach_id = wp_insert_attachment($attachment, $filename, $post_id);
                 $attach_data = wp_generate_attachment_metadata($attach_id, $filename);
                 wp_update_attachment_metadata($attach_id, $attach_data);
                 // this is necessary, or _wp_post_thumbnail_html returns broken remove link
                 $post_ID = $post_id;
                 // set_post_thumbnail available only since WordPress 3.1
                 if (set_post_thumbnail($post_id, $attach_id)) {
                     die(json_encode(array('html' => _wp_post_thumbnail_html($attach_id), 'attach_id' => $attach_id)));
                 } else {
                     $this->ajax_error(new WP_Error(1, __('An unexpected error occurred.', 'zemanta')));
                 }
             } else {
                 $this->ajax_error(new WP_Error(2, sprintf(__('An upload error occurred: %s', 'zemanta'), $upload->get_error_message())));
             }
         } else {
             $this->ajax_error(new WP_Error(3, sprintf(__('An error occurred while image download: %s', 'zemanta'), $http_response->get_error_message())));
         }
     }
     die(0);
 }
开发者ID:StudentLifeMarketingAndDesign,项目名称:krui-wp,代码行数:48,代码来源:zemanta.php

示例9: audiotheme_ajax_get_video_oembed_data

/**
 * AJAX method to retrieve the thumbnail for a video.
 *
 * @since 1.0.0
 */
function audiotheme_ajax_get_video_oembed_data()
{
    global $post_id;
    $post_id = absint($_POST['post_id']);
    $json['post_id'] = $post_id;
    add_filter('oembed_dataparse', 'audiotheme_parse_video_oembed_data', 1, 3);
    $oembed = wp_oembed_get($_POST['video_url']);
    if ($thumbnail_id = get_post_thumbnail_id($post_id)) {
        $json['thumbnail_id'] = $thumbnail_id;
        $json['thumbnail_url'] = wp_get_attachment_url($thumbnail_id);
        $json['thumbnail_meta_box_html'] = _wp_post_thumbnail_html($thumbnail_id, $post_id);
    }
    wp_send_json($json);
}
开发者ID:TyRichards,项目名称:ty_the_band,代码行数:19,代码来源:videos.php

示例10: openbadger_ajax_badgedesigner_publish

/**
 * AJAX callback that handles a JSON response from OpenBadges.me, saves the image in
 * the media library, and then sets it as the post feature image.
 */
function openbadger_ajax_badgedesigner_publish()
{
    /* checks copied from wp-admin/async-upload.php */
    nocache_headers();
    /* copied from wp-admin/includes/ajax-actions.php wp_ajax_upload_attachment */
    check_ajax_referer('openbadger-badgedesigner', 'nonce');
    if (!current_user_can('upload_files')) {
        wp_die();
    }
    $post_id = null;
    if (isset($_POST['post_id'])) {
        $post_id = $_POST['post_id'];
        if (!current_user_can('edit_post', $post_id)) {
            wp_die();
        }
    }
    $badge_source = $_POST['badge_source'];
    if (empty($badge_source)) {
        $badge_source = 'openbadges.me';
    }
    $post_data = array();
    $stash = array();
    switch ($badge_source) {
        case 'openbadges.me':
            $_f = openbadger_badgedesigner_openbadges_pre_upload($post_id, stripslashes($_POST['badge']), $post_data, $stash);
            break;
    }
    /* DO THE UPLOAD. HOORAY! */
    $attachment_id = _openbadger_badgedesigner_media_handle_upload($_f, $post_id, $post_data, array('test_form' => false, 'mimes' => array('png' => 'image/png')));
    if (is_wp_error($attachment_id)) {
        wp_send_json_error(array('message' => $attachment_id->get_error_message(), 'filename' => $_f['name']));
    }
    add_post_meta($attachment_id, 'openbadger-badgedesigner-source', $badge_source, true);
    switch ($badge_source) {
        case 'openbadges.me':
            openbadger_badgedesigner_openbadges_post_upload($post_id, $attachment_id, $stash);
            break;
    }
    if (!set_post_thumbnail($post_id, $attachment_id)) {
        wp_send_json_error(array('message' => __('Unable to set the badge as the featured image.', 'rpibadger'), 'filename' => $_f['name']));
    }
    if (!($attachment = wp_prepare_attachment_for_js($attachment_id))) {
        wp_die();
    }
    $attachment['postimagediv'] = _wp_post_thumbnail_html($attachment_id, $post_id);
    wp_send_json_success($attachment);
}
开发者ID:johappel,项目名称:open-badger,代码行数:51,代码来源:badges_designer.php

示例11: post_thumbnail_meta_box

 /**
  * Display featured image meta box on slide edit modal
  */
 public function post_thumbnail_meta_box($post)
 {
     remove_all_filters('admin_post_thumbnail_html');
     $thumbnail_id = get_post_meta($post->ID, '_thumbnail_id', true);
     echo _wp_post_thumbnail_html($thumbnail_id, $post->ID);
 }
开发者ID:proudchild,项目名称:sdmblog,代码行数:9,代码来源:class-fa-admin.php

示例12: set_thumbnail_ajax

 /**
  * Ajax callback to initiate the change of a Post default thumbnail
  * @return string HTML code to update the Post page to display the new thumbnail
  */
 public function set_thumbnail_ajax()
 {
     $this->check_nonce_and_permissions($_POST['action']);
     global $post_ID;
     if (!isset($_POST['id'])) {
         wp_send_json_error("Post ID not found");
     }
     $post_ID = intval($_POST['id']);
     if (!$post_ID) {
         wp_send_json_error("Illegal Post ID");
     }
     $url = isset($_POST['img']) ? $_POST['img'] : '';
     $thumbnail_id = $this->set_thumbnail(esc_url_raw($url), $post_ID);
     if ($thumbnail_id !== false) {
         set_post_thumbnail($post_ID, $thumbnail_id);
         wp_send_json_success(_wp_post_thumbnail_html($thumbnail_id, $post_ID));
     }
     //TODO: Better error
     wp_send_json_error("Something went wrong");
 }
开发者ID:gopinathshiva,项目名称:wordpress-vip-plugins,代码行数:24,代码来源:thePlatform-proxy.php

示例13: ooyala_set

 /**
  * Ajax callback that sets a post thumbnail based on an ooyala embed id
  *
  * @uses OoyalaBacklotAPI::get_promo_thumbnail to get the thumbnail url
  * @uses Ooyala_Video::set_thumbnail() to set fetch the image an set it
  * @uses core's set_post_thumbnail() to set the link between post and thumbnail id
  *
  * output html block for the meta box (from _wp_post_thumbnail_html() )
  */
 function ooyala_set()
 {
     global $post_ID;
     $nonce = isset($_POST['_wpnonce']) ? $_POST['_wpnonce'] : '';
     if (!wp_verify_nonce($nonce, 'ooyala')) {
         die('Security check');
     }
     $_post_id = absint($_POST['postid']);
     // Make sure the global is set, otherwise the nonce check in set_post_thumbnail() will fail
     $post_ID = (int) $_post_id;
     //Let's set the thumbnails size
     if (isset($_wp_additional_image_sizes['post-thumbnail'])) {
         $thumbnail_width = $_wp_additional_image_sizes['post-thumbnail']['width'];
         $thumbnail_height = $_wp_additional_image_sizes['post-thumbnail']['height'];
     } else {
         $thumbnail_width = 640;
         $thumbnail_height = 640;
     }
     $url = isset($_POST['img']) ? esc_attr($_POST['img']) : '';
     $thumbnail_id = $this->set_thumbnail($url, $_post_id);
     if (false !== $thumbnail_id) {
         set_post_thumbnail($_post_id, $thumbnail_id);
         die(_wp_post_thumbnail_html($thumbnail_id));
     }
 }
开发者ID:humanmade,项目名称:vip-mu-plugins-public,代码行数:34,代码来源:ooyala.php

示例14: file_gallery_main


//.........这里部分代码省略.........
            if (current_user_can('delete_post', $normal)) {
                wp_delete_attachment($normal);
                $fully_deleted[] = $normal;
            }
        }
        foreach ($copies as $copy) {
            if (current_user_can('delete_post', $copy)) {
                file_gallery_delete_attachment($copy);
                $partially_deleted[] = $copy;
            }
        }
        foreach ($originals as $original) {
            if ("all" == $delete_what && current_user_can('delete_post', $original)) {
                file_gallery_delete_all_attachment_copies($original);
                wp_delete_attachment($original);
                $fully_deleted[] = $original;
            } elseif ("data_only" == $delete_what && current_user_can('delete_post', $original)) {
                file_gallery_promote_first_attachment_copy($original);
                file_gallery_delete_attachment($original);
                $partially_deleted[] = $original;
            }
        }
        if (empty($fully_deleted) && empty($partially_deleted)) {
            $output = __("No attachments were deleted (capabilities?)", "file-gallery");
        } else {
            $output = __("Attachment(s) deleted", "file-gallery");
        }
    } elseif ("file_gallery_main_detach" == $action) {
        foreach ($attachment_ids as $attachment_id) {
            if (false === $wpdb->query(sprintf("UPDATE {$wpdb->posts} SET `post_parent`='0' WHERE `ID`='%d'", $attachment_id))) {
                $detach_errors[] = $attachment_id;
            }
        }
        if (empty($detach_errors)) {
            $output = __("Attachment(s) detached", "file-gallery");
        } else {
            $output = __("Error detaching attachment(s)", "file-gallery");
        }
    } elseif ("file_gallery_main_update" == $action) {
        $attachment_id = (int) $_POST['attachment_id'];
        $attachment_data['ID'] = $attachment_id;
        $attachment_data['post_alt'] = $_POST['post_alt'];
        $attachment_data['post_title'] = $_POST['post_title'];
        $attachment_data['post_content'] = $_POST['post_content'];
        $attachment_data['post_excerpt'] = $_POST['post_excerpt'];
        $attachment_data['menu_order'] = $_POST['menu_order'];
        // attachment custom fields
        $custom = get_post_custom($attachment_id);
        $custom_fields = isset($_POST['custom_fields']) ? $_POST['custom_fields'] : '';
        if (!empty($custom) && !empty($custom_fields)) {
            foreach ($custom_fields as $key => $val) {
                if (isset($custom[$key]) && $custom[$key][0] != $val) {
                    update_post_meta($attachment_id, $key, $val);
                }
            }
        }
        // media_tag taxonomy - attachment tags
        $tax_input = "";
        $old_media_tags = "";
        $get_old_media_tags = wp_get_object_terms((int) $_POST['attachment_id'], FILE_GALLERY_MEDIA_TAG_NAME);
        if (!empty($get_old_media_tags)) {
            foreach ($get_old_media_tags as $mt) {
                $old_media_tags[] = $mt->name;
            }
            $old_media_tags = implode(", ", $old_media_tags);
        }
        if ("" != $_POST['tax_input'] && $old_media_tags != $_POST['tax_input']) {
            $tax_input = preg_replace("#\\s+#", " ", $_POST['tax_input']);
            $tax_input = preg_replace("#,+#", ",", $_POST['tax_input']);
            $tax_input = trim($tax_input, " ");
            $tax_input = trim($tax_input, ",");
            $tax_input = explode(", ", $tax_input);
            $media_tags_result = wp_set_object_terms($attachment_id, $tax_input, FILE_GALLERY_MEDIA_TAG_NAME);
        } elseif ("" == $_POST['tax_input']) {
            $media_tags_result = wp_set_object_terms($attachment_id, NULL, FILE_GALLERY_MEDIA_TAG_NAME);
        }
        // check if there were any changes
        $old_attachment_data = get_object_vars(get_post($attachment_id));
        if (file_gallery_file_is_displayable_image(get_attached_file($attachment_id))) {
            $old_attachment_data['post_alt'] = get_post_meta($attachment_id, "_wp_attachment_image_alt", true);
        }
        if (isset($old_attachment_data['post_alt']) && $old_attachment_data['post_alt'] != $attachment_data['post_alt'] || $old_attachment_data['post_title'] != $attachment_data['post_title'] || $old_attachment_data['post_content'] != $attachment_data['post_content'] || $old_attachment_data['post_excerpt'] != $attachment_data['post_excerpt'] || $old_attachment_data['menu_order'] != $attachment_data['menu_order'] || is_array($tax_input)) {
            if (0 !== wp_update_post($attachment_data)) {
                update_post_meta($attachment_id, "_wp_attachment_image_alt", $attachment_data['post_alt']);
                $output = __("Attachment data updated", "file-gallery");
            } else {
                $output = __("Error updating attachment data!", "file-gallery");
            }
        } else {
            $output = __("No change.", "file-gallery");
        }
    } elseif ("file_gallery_set_post_thumb" == $action) {
        update_post_meta($post_id, "_thumbnail_id", $attachment_ids[0]);
        exit(_wp_post_thumbnail_html($attachment_ids[0], $post_id));
    } elseif ("file_gallery_unset_post_thumb" == $action) {
        exit;
    }
    include_once "main-form.php";
    exit;
}
开发者ID:kyme-online,项目名称:Ramesh-Photography,代码行数:101,代码来源:main.php

示例15: new_post_thumbnail_meta_box

function new_post_thumbnail_meta_box()
{
    global $post;
    // we know what this does
    /*if ($post->post_type=='downloads') {
    		echo '<strong>Image Size:</strong> 90px X 127px';
    	} else {
    	};
    	*/
    echo '<strong>Important!</strong><br>Upload images that are at least <strong>1600x666 pixels</strong> or will cause issues on some pages!<br>Gallery images should be bigger but limited to about 2048x1536 for optimum results.';
    $thumbnail_id = get_post_meta($post->ID, '_thumbnail_id', true);
    // grabing the thumbnail id of the post
    echo _wp_post_thumbnail_html($thumbnail_id);
    // echoing the html markup for the thumbnail
}
开发者ID:JackBrit,项目名称:Team-London-Bridge,代码行数:15,代码来源:functions.php


注:本文中的_wp_post_thumbnail_html函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。