本文整理汇总了PHP中get_post_thumbnail_id函数的典型用法代码示例。如果您正苦于以下问题:PHP get_post_thumbnail_id函数的具体用法?PHP get_post_thumbnail_id怎么用?PHP get_post_thumbnail_id使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了get_post_thumbnail_id函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: charity_vc_our_mission
function charity_vc_our_mission($atts, $content = null)
{
extract(shortcode_atts(array('our_mission' => ''), $atts));
$page_id = get_page_by_title($our_mission);
$missionQuery = new WP_Query(array("page_id" => $page_id->ID));
if ($missionQuery->have_posts()) {
$missionQuery->the_post();
$url = wp_get_attachment_image_src(get_post_thumbnail_id($page_id->ID), array(1143, 479));
?>
<!-- Save Lives Section Start Here-->
<section class="save-lives text-center parallax" style="background-image: url('<?php
echo esc_url($url[0]);
?>
')">
<div class="container">
<div class="row">
<div class="col-xs-12 col-sm-8 col-sm-offset-2 col-md-6 col-md-offset-3">
<header class="page-header">
<h2><?php
the_title();
?>
</h2>
<?php
the_content();
?>
</header>
</div>
</div>
</div>
</section>
<!-- Save Lives Section Start Here-->
<?php
}
wp_reset_postdata();
}
示例2: ya_product_thumbnail
function ya_product_thumbnail($size = 'shop_catalog', $placeholder_width = 0, $placeholder_height = 0)
{
global $post;
$html = '';
$id = get_the_ID();
$gallery = get_post_meta($id, '_product_image_gallery', true);
$attachment_image = '';
if (!empty($gallery)) {
$gallery = explode(',', $gallery);
$first_image_id = $gallery[0];
$attachment_image = wp_get_attachment_image($first_image_id, $size, false, array('class' => 'hover-image back'));
}
$image = wp_get_attachment_image_src(get_post_thumbnail_id($post->ID), '');
if (has_post_thumbnail()) {
if ($attachment_image) {
$html .= '<div class="product-thumb-hover">';
$html .= get_the_post_thumbnail($post->ID, $size) ? get_the_post_thumbnail($post->ID, $size) : '<img src="' . get_template_directory_uri() . '/assets/img/placeholder/' . $size . '.png" alt="No thumb">';
$html .= $attachment_image;
$html .= '</div>';
/* quickview */
$nonce = wp_create_nonce("ya_quickviewproduct_nonce");
$link = admin_url('admin-ajax.php?ajax=true&action=ya_quickviewproduct&post_id=' . $post->ID . '&nonce=' . $nonce);
$html .= '<a href="' . $link . '" data-fancybox-type="ajax" class="group fancybox fancybox.ajax">' . apply_filters('out_of_stock_add_to_cart_text', __('Quick View ', 'yatheme')) . '</a>';
} else {
$html .= get_the_post_thumbnail($post->ID, $size) ? get_the_post_thumbnail($post->ID, $size) : '<img src="' . get_template_directory_uri() . '/assets/img/placeholder/' . $size . '.png" alt="No thumb">';
}
return $html;
} else {
$html .= '<img src="' . get_template_directory_uri() . '/assets/img/placeholder/' . $size . '.png" alt="No thumb">';
return $html;
}
}
示例3: get_grid_archive_theme
/**
* Returns classic grid element for a given product
*
* @param object $post Product post object
* @param string $archive_template
* @return string
*/
function get_grid_archive_theme($post, $archive_template = null)
{
$archive_template = isset($archive_template) ? $archive_template : get_product_listing_template();
$return = '';
if ($archive_template == 'grid') {
$image_id = get_post_thumbnail_id($post->ID);
$thumbnail_product = wp_get_attachment_image_src($image_id, 'classic-grid-listing');
$product_name = get_product_name();
if ($thumbnail_product) {
$img_class['alt'] = $product_name;
$img_class['class'] = 'classic-grid-image';
$image = wp_get_attachment_image($image_id, 'classic-grid-listing', false, $img_class);
} else {
$url = default_product_thumbnail_url();
$image = '<img src="' . $url . '" class="classic-grid-image" alt="' . $product_name . '" >';
}
$archive_price = apply_filters('archive_price_filter', '', $post);
$classic_grid_settings = get_classic_grid_settings();
$row_class = get_row_class($classic_grid_settings);
$return = '<div class="archive-listing product-' . $post->ID . ' classic-grid ' . $row_class . ' ' . product_class($post->ID) . '">';
$return .= '<a href="' . get_permalink() . '">';
//$return .= '<div style="background-image:url(\'' . $url . '\');" class="classic-grid-element"></div>';
$return .= '<div class="classic-grid-image-wrapper"><div class="pseudo"></div><div class="image">' . $image . '</div></div>';
$return .= '<h3 class="product-name">' . $product_name . '</h3>' . $archive_price . '</a></div>';
}
return $return;
}
示例4: vr_set_featured_background
function vr_set_featured_background()
{
$page_for_posts = get_option('page_for_posts');
$image_url = wp_get_attachment_image_src(get_post_thumbnail_id($page_for_posts), full, false);
if ($image_url[0]) {
?>
<style>
html,body {
height:100%;
margin:0!important;
}
body {
background:url(<?php
echo $image_url[0];
?>
) #fff center center repeat;
}
.wrapper {
height: auto;
}
</style>
<?php
}
//end if statement
}
示例5: al_portfolio_meta_tags
function al_portfolio_meta_tags()
{
$post_type = get_post_type();
if ('portfolio' == $post_type) {
$title = get_post_meta(get_the_ID(), "al_pf_og_title", TRUE);
$title = !empty($title) ? $title : get_the_title();
$meta = array('og:title' => $title, 'og:url' => get_permalink());
$desc = get_post_meta(get_the_ID(), "al_pf_og_description", TRUE);
$desc = !empty($desc) ? $desc : false;
if ($desc) {
$meta['og:description'] = $desc;
}
if (has_post_thumbnail()) {
$thumbnail = wp_get_attachment_image_src(get_post_thumbnail_id(), 'full');
$meta['og:image'] = $thumbnail[0];
}
if (get_post_format() == 'gallery') {
$images = rwmb_meta('al_pf_gallery_images', 'type=image&size=full');
if (is_array($images)) {
foreach ($images as $image) {
$meta['images'][] = $image['url'];
}
}
}
foreach ($meta as $key => $value) {
if ($key == 'images') {
foreach ($value as $image) {
echo '<meta property="og:image" content="' . $image . '" />';
}
} else {
echo '<meta property="' . $key . '" content="' . $value . '" />';
}
}
}
}
示例6: ac_render_ac_easy_slideshow
function ac_render_ac_easy_slideshow($full_width = false, $type = 'royalslider')
{
// We need to build an array of posts to pass through to the RoyalSlider function
$posts = array();
// Should we include the featured image?
if (has_post_thumbnail() && ac_get_meta('include_featured_image') == 1) {
$posts[] = get_post(get_post_thumbnail_id());
}
// Get the images to use
$images = ac_get_meta('images', array('type' => 'image_advanced'));
// Add them to the slides
foreach ($images as $image) {
// Add to our slides
$posts[] = get_post($image['ID']);
}
$args = array('slider_style' => 'no-caption', 'slider_size' => 'square', 'class' => 'ac_easy_slider');
if ($full_width) {
$args['full_width'] = true;
}
// Render the slideshow
if (count($posts)) {
if ($type == 'royalslider') {
echo ac_render_posts_slideshow($args, $posts);
} else {
echo ac_render_slick_carousel($args, $posts);
}
return true;
}
return false;
}
示例7: get_data
/**
* Compile the schema.org event data into an array
*/
public function get_data($post = null, $args = array())
{
if (!$post instanceof WP_Post) {
$post = Tribe__Main::post_id_helper($post);
}
$post = get_post($post);
if (!$post instanceof WP_Post) {
return array();
}
$data = (object) array();
// We may need to prevent the context to be triggered
if (!isset($args['context']) || false !== $args['context']) {
$data->{'@context'} = 'http://schema.org';
}
$data->{'@type'} = $this->type;
$data->name = esc_js(get_the_title($post));
$data->description = esc_js(tribe_events_get_the_excerpt($post));
if (has_post_thumbnail($post)) {
$data->image = wp_get_attachment_url(get_post_thumbnail_id($post));
}
$data->url = esc_url_raw(get_permalink($post));
// Index by ID: this will allow filter code to identify the actual event being referred to
// without injecting an additional property
return array($post->ID => $data);
}
示例8: build_data
/**
* Compile the schema.org event data into an array
*/
private function build_data()
{
global $post;
$id = $post->ID;
$events_data = array();
// Index by ID: this will allow filter code to identify the actual event being referred to
// without injecting an additional property
$events_data[$id] = new stdClass();
$events_data[$id]->{'@context'} = 'http://schema.org';
$events_data[$id]->{'@type'} = 'Event';
$events_data[$id]->name = get_the_title();
if (has_post_thumbnail()) {
$events_data[$id]->image = wp_get_attachment_url(get_post_thumbnail_id($post->ID));
}
$events_data[$id]->url = get_the_permalink($post->ID);
$events_data[$id]->startDate = get_gmt_from_date(tribe_get_start_date($post, true, TribeDateUtils::DBDATETIMEFORMAT), 'c');
$events_data[$id]->endDate = get_gmt_from_date(tribe_get_end_date($post, true, TribeDateUtils::DBDATETIMEFORMAT), 'c');
if (tribe_has_venue($id)) {
$events_data[$id]->location = new stdClass();
$events_data[$id]->location->{'@type'} = 'Place';
$events_data[$id]->location->name = tribe_get_venue($post->ID);
$events_data[$id]->location->address = strip_tags(str_replace("\n", '', tribe_get_full_address($post->ID)));
}
/**
* Allows the event data to be modifed by themes and other plugins.
*
* @param array $events_data objects representing the Google Markup for each event.
*/
$events_data = apply_filters('tribe_google_event_data', $events_data);
// Strip the post ID indexing before returning
$events_data = array_values($events_data);
return $events_data;
}
示例9: dfi_download_featured_images
/**
*
* @global type $post
*
*/
function dfi_download_featured_images()
{
global $post;
//get featured enable lists
$post_options = (array) json_decode(get_option('featured_enable'));
$singular = '';
$is_page = '';
if (!empty($post_options['page'])) {
$is_page = is_page();
unset($post_options['page']);
}
if (!empty($post_options)) {
$post_options = array_values($post_options);
$singular = is_singular($post_options);
} else {
$singular = $is_page;
}
if (!empty($post_options) && $is_page != '') {
$singular = $is_page || $singular;
}
// echo '<pre>';
// print_r($post_options);
// exit;
if ($singular && has_post_thumbnail()) {
$url = wp_get_attachment_image_src(get_post_thumbnail_id($post->ID), 'single-post-thumbnail');
$icon = get_post_meta($post->ID, 'featured_download', true);
if ($url[0] != '' && $icon == 'yes') {
dfi_add_download_button($url[0]);
}
}
}
示例10: get_tour_info
function get_tour_info()
{
$tourinfo = array();
$tour_ID = get_the_ID();
$tour_title = get_the_title();
$tour_feat_image_url = get_no_img_url();
if (has_post_thumbnail()) {
$tour_feat_image_url = wp_get_attachment_url(get_post_thumbnail_id());
}
$tour_excerpt = get_the_excerpt();
$tour_post_link = get_permalink($tour_ID);
$tour_departure = get_location_ID(get_post_meta($tour_ID, 'tour_departure', true));
$tour_arrival = get_location_ID(get_post_meta($tour_ID, 'tour_arrival', true));
$tour_price = get_post_meta($tour_ID, 'tour_price', true);
$tour_price_discount = get_post_meta($tour_ID, 'tour_price_discount', true);
$tour_start = get_post_meta($tour_ID, 'tour_start', true);
$tour_end = get_post_meta($tour_ID, 'tour_end', true);
$tour_days = get_post_meta($tour_ID, 'tour_days', true);
$tourinfo['tour_ID'] = $tour_ID;
$tourinfo['tour_title'] = $tour_title;
$tourinfo['tour_feat_image_url'] = $tour_feat_image_url;
$tourinfo['tour_excerpt'] = $tour_excerpt;
$tourinfo['tour_post_link'] = $tour_post_link;
$tourinfo['tour_departure'] = $tour_departure;
$tourinfo['tour_arrival'] = $tour_arrival;
$tourinfo['tour_price'] = $tour_price;
$tourinfo['tour_price_discount'] = $tour_price_discount;
$tourinfo['tour_start'] = $tour_start;
$tourinfo['tour_end'] = $tour_end;
$tourinfo['tour_days'] = $tour_days;
return $tourinfo;
}
示例11: skeleton_og_meta_tags
/**
* Display the Open Graph meta tags.
* Add more to this if needed.
*
* See: https://developers.facebook.com/docs/sharing/webmasters and http://ogp.me/
*/
function skeleton_og_meta_tags()
{
if (is_single() || is_page()) {
if (have_posts()) {
while (have_posts()) {
the_post();
?>
<meta name="og:description" content="<?php
the_excerpt_rss();
?>
">
<meta name="og:image" content="<?php
echo skeleton_get_thumbnail_src(get_post_thumbnail_id());
?>
">
<?php
}
}
} elseif (is_home()) {
?>
<meta name="og:description" content="<?php
bloginfo('description');
?>
">
<?php
}
}
示例12: post_thumbnail_src
function post_thumbnail_src()
{
global $post;
if ($values = get_post_custom_values("thumb")) {
//输出自定义域图片地址
$values = get_post_custom_values("thumb");
$post_thumbnail_src = $values[0];
} elseif (has_post_thumbnail()) {
//如果有特色缩略图,则输出缩略图地址
$thumbnail_src = wp_get_attachment_image_src(get_post_thumbnail_id($post->ID), 'full');
$post_thumbnail_src = $thumbnail_src[0];
} else {
$post_thumbnail_src = '';
ob_start();
ob_end_clean();
$output = preg_match_all('/<img.+src=[\'"]([^\'"]+)[\'"].*>/i', $post->post_content, $matches);
$post_thumbnail_src = $matches[1][0];
//获取该图片 src
if (empty($post_thumbnail_src)) {
//如果日志中没有图片,则显示随机图片
$random = mt_rand(1, 10);
echo get_bloginfo('template_url');
echo '/images/random/' . $random . '.jpg';
//如果日志中没有图片,则显示默认图片
//echo '/images/default_thumb.jpg';
}
}
echo $post_thumbnail_src;
}
示例13: erm_get_menu_item_data
/**
* Get post type erm_menu_item data
*
* @since 1.0
* @param $id
* @return array
*/
function erm_get_menu_item_data($id)
{
$post = get_post($id);
if ($post && get_post_type($id) == 'erm_menu_item') {
$visible = get_post_meta($id, '_erm_visible', true);
if (has_post_thumbnail($id)) {
$thumbnail_id = get_post_thumbnail_id($id);
$image_src_thumb = wp_get_attachment_image_src($thumbnail_id);
$image_src_thumb = isset($image_src_thumb[0]) ? $image_src_thumb[0] : '';
$image_src_big = wp_get_attachment_image_src($thumbnail_id, 'full');
$image_src_big = isset($image_src_big[0]) ? $image_src_big[0] : '';
$post_image = get_post($thumbnail_id);
$image_title = $post_image->post_excerpt;
$image_desc = $post_image->post_content;
} else {
$thumbnail_id = 0;
$image_src_thumb = '';
$image_src_big = '';
$image_title = '';
$image_desc = '';
}
$prices = get_post_meta($id, '_erm_prices', true);
return array('id' => intval($id), 'type' => get_post_meta($id, '_erm_type', true), 'visible' => $visible ? 1 : 0, 'title' => $post->post_title, 'content' => $post->post_content, 'image_id' => intval($thumbnail_id), 'src_thumb' => $image_src_thumb, 'src_big' => $image_src_big, 'image_title' => $image_title, 'image_desc' => $image_desc, 'prices' => $prices, 'link' => get_edit_post_link($id));
}
return array();
}
示例14: afi_metabox
/**
* Markup for the advanced featured image metabox.
*
* @param string $content Content in the featured image metabox.
* @param number $post_id Id of the post we are on.
*
* @return string Content for the featured image.
*/
function afi_metabox($content, $post_id)
{
wp_nonce_field('afi_metabox_' . $post_id, 'afi_metabox_nonce');
$image_url = get_post_meta($post_id, '_afi_img_src', true);
if (!$image_url) {
$post_thumbnail_id = get_post_thumbnail_id($post_id);
if ('' !== $post_thumbnail_id) {
$image_url = wp_get_attachment_url($post_thumbnail_id);
}
}
$content = '<div id="custom_image_container">';
if ($image_url) {
$content .= '<img src="' . $image_url . '" style="max-width:100%;" />';
}
$content .= '</div>';
// Add & remove image links.
$content .= '<p class="hide-if-no-js">';
$content .= '<a class="upload-custom-img ' . ($image_url ? 'hidden' : '') . '" href="#">';
$content .= __('Set custom image', 'tutsplus');
$content .= '</a>';
$content .= '<a class="delete-custom-img ' . (!$image_url ? 'hidden' : '') . '" href="#">';
$content .= __('Remove this image', 'tutsplus');
$content .= '</a>';
$content .= '</p>';
// Hidden input to set the chosen image url on post.
$content .= '<input class="afi-img-id" name="afi-img-src" type="hidden" value="' . esc_url($image_url) . '" />';
return $content;
}
示例15: sfc_media_find_images
function sfc_media_find_images($post, $content = '')
{
if (empty($content)) {
$content = apply_filters('the_content', $post->post_content);
}
$images = array();
// we get the post thumbnail, put it first in the image list
if (current_theme_supports('post-thumbnails') && has_post_thumbnail($post->ID)) {
$thumbid = get_post_thumbnail_id($post->ID);
$att = wp_get_attachment_image_src($thumbid, 'full');
if (!empty($att[0])) {
$images[] = $att[0];
}
}
if (is_attachment() && preg_match('!^image/!', get_post_mime_type($post))) {
$images[] = wp_get_attachment_url($post->ID);
}
// now search for images in the content itself
if (preg_match_all('/<img\\s+(.+?)>/i', $content, $matches)) {
foreach ($matches[1] as $match) {
foreach (wp_kses_hair($match, array('http')) as $attr) {
$img[strtolower($attr['name'])] = $attr['value'];
}
if (isset($img['src'])) {
if (!isset($img['class']) || isset($img['class']) && false === straipos($img['class'], apply_filters('sfc_img_exclude', array('wp-smiley')))) {
// ignore smilies
if (!in_array($img['src'], $images) && strpos($img['src'], 'fbcdn.net') === false && strpos($img['src'], '/plugins/') === false) {
$images[] = $img['src'];
}
}
}
}
}
return $images;
}