本文整理汇总了PHP中wp_get_attachment_thumb_url函数的典型用法代码示例。如果您正苦于以下问题:PHP wp_get_attachment_thumb_url函数的具体用法?PHP wp_get_attachment_thumb_url怎么用?PHP wp_get_attachment_thumb_url使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了wp_get_attachment_thumb_url函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: mtheme_portfolio_custom_columns
function mtheme_portfolio_custom_columns($column)
{
global $post;
$custom = get_post_custom();
$image_url = wp_get_attachment_thumb_url(get_post_thumbnail_id($post->ID));
$full_image_id = get_post_thumbnail_id($post->ID, 'thumbnail');
$full_image_url = wp_get_attachment_image_src($full_image_id, 'thumbnail');
$full_image_url = $full_image_url[0];
if (!defined('MTHEME')) {
$mtheme_shortname = "mtheme_p2";
define('MTHEME', $mtheme_shortname);
}
switch ($column) {
case "portfolio_image":
if (isset($image_url)) {
echo '<a class="thickbox" href="' . $full_image_url . '"><img src="' . $image_url . '" width="60px" height="60px" alt="featured" /></a>';
} else {
echo __('Image not found', 'mthemelocal');
}
break;
case "description":
if (isset($custom[MTHEME . '_thumbnail_desc'][0])) {
echo $custom[MTHEME . '_thumbnail_desc'][0];
}
break;
case "video":
if (isset($custom[MTHEME . '_lightbox_video'][0])) {
echo $custom[MTHEME . '_lightbox_video'][0];
}
break;
case "types":
echo get_the_term_list($post->ID, 'types', '', ', ', '');
break;
}
}
示例2: mtheme_fullscreen_custom_columns
function mtheme_fullscreen_custom_columns($column)
{
global $post;
$custom = get_post_custom();
$image_url = wp_get_attachment_thumb_url(get_post_thumbnail_id($post->ID));
$full_image_id = get_post_thumbnail_id($post->ID, 'thumbnail');
$full_image_url = wp_get_attachment_image_src($full_image_id, 'thumbnail');
$full_image_url = $full_image_url[0];
if (!defined('MTHEME')) {
$mtheme_shortname = "mtheme_p2";
define('MTHEME', $mtheme_shortname);
}
switch ($column) {
case "featured_image":
if (isset($image_url)) {
echo '<a class="thickbox" href="' . $full_image_url . '"><img src="' . $image_url . '" width="40px" height="40px" alt="featured" /></a>';
} else {
echo 'Image not found';
}
break;
case "featured_description":
if (isset($custom["featured_description"][0])) {
echo $custom["featured_description"][0];
}
break;
case "fullscreen_type":
if (isset($custom["fullscreen_type"][0])) {
echo $custom["fullscreen_type"][0];
}
break;
}
}
示例3: display_images_from_media_library
function display_images_from_media_library($type, $mediaID = NULL)
{
if ($type == 'bg') {
$thumb_type = 'st-bg-thumb';
} else {
$thumb_type = 'st-thumb';
}
if ($mediaID == NULL || $mediaID == 0) {
$image_return = '<img style="opacity: 1; filter: alpha(opacity=100);" width="80" height="80" class="thumb ' . $thumb_type . '" src="' . plugins_url('images/no-image.png', __FILE__) . '" alt="" data-pid="" />';
} else {
$image_return = '<img style="opacity: 0.2; filter: alpha(opacity=2);" width="80" height="80" class="thumb ' . $thumb_type . '" src="' . plugins_url('images/no-image.png', __FILE__) . '" alt="" data-pid="" />';
}
$images = get_children(array('post_type' => 'attachment', 'post_mime_type' => 'image', 'order' => 'ASC', 'orderby' => 'menu_order'));
if ($images) {
foreach ($images as $id => $image) {
$opacity_out = 'style="opacity: 0.2; filter: alpha(opacity=2);"';
if ($mediaID !== NULL) {
if ($image->ID == $mediaID) {
$opacity_out = 'style="opacity: 1; filter: alpha(opacity=100);"';
}
}
$img = wp_get_attachment_thumb_url($image->ID);
$image_return .= '<img ' . @$opacity_out . 'width="80" height="80" class="thumb ' . $thumb_type . '" src="' . $img . '" alt="" data-pid="' . $image->ID . '" />';
}
}
return $image_return;
}
示例4: output
/**
* Check AM_MBF for description.
*
* @todo Set class on div to set if the image has been selected and get rid of $hide_upload_button and $hide_clear_button.
*
* @since 1.0.0
*/
public function output()
{
// Get the file id, 0 represents a new field.
$image_id = intval($this->value) > 0 ? intval($this->value) : 0;
$image_url = '';
$image_title = '';
$class_icon = '';
$hide_upload_button = $hide_clear_button = ' style="display:none;"';
// Make sure the selected image is valid.
if ($image_id > 0) {
$post = get_post($image_id);
if (isset($post) && wp_attachment_is_image($image_id)) {
$image_url = wp_get_attachment_thumb_url($image_id);
$image_title = $post->post_title;
} else {
$this->error = __(sprintf('Selected Image (ID:%1$d) is invalid.', $image_id), 'am-cpts');
$class_icon = ' invalid';
}
$hide_clear_button = '';
} else {
$hide_upload_button = '';
}
// Text used by wp.media frame.
$wp_media_data = sprintf(' data-title="%1$s" data-button="%2$s"', esc_attr__('Choose an Image', 'am-cpts'), esc_attr__('Use this Image', 'am-cpts'));
return sprintf('
<div%11$s>
<input name="%2$s" type="hidden" class="meta-box-upload-image" value="%1$d"%12$s />
<img src="%10$s" class="meta-box-preview-image%3$s" title="%7$s" alt="%6$s"%5$s />
<a href="#" class="meta-box-upload-image-button button"%4$s%13$s>%8$s</a>
<span class="meta-box-image-title"%5$s>%6$s</span>
<a href="#" class="meta-box-clear-image-button"%5$s>%9$s</a>
</div>', esc_attr($image_id), esc_attr($this->name), $class_icon, $hide_upload_button, $hide_clear_button, isset($this->error) ? esc_html($this->error) : $image_title, esc_attr__('Selected Image', 'am-cpts'), esc_html__('Choose Image', 'am-cpts'), esc_html__('Remove Image', 'am-cpts'), esc_url($image_url), $this->get_classes('meta-box-image'), $this->get_data_atts(), $wp_media_data);
}
示例5: mtheme_sort_portfolio
/**
* Display Sort admin
*
* @return void
* @author Soul
**/
function mtheme_sort_portfolio()
{
$portfolio = new WP_Query('post_type=mtheme_portfolio&posts_per_page=-1&orderby=menu_order&order=ASC');
?>
<div class="wrap">
<h2>Sort portfolio Slides<img src="<?php
echo home_url();
?>
/wp-admin/images/loading.gif" id="loading-animation" /></h2>
<div class="description">
Drag and Drop the slides to order them
</div>
<ul id="portfolio-list">
<?php
while ($portfolio->have_posts()) {
$portfolio->the_post();
?>
<li id="<?php
the_id();
?>
">
<div>
<?php
$image_url = wp_get_attachment_thumb_url(get_post_thumbnail_id());
$custom = get_post_custom(get_the_ID());
$portfolio_cats = get_the_terms(get_the_ID(), 'types');
?>
<?php
if ($image_url) {
echo '<img class="mtheme_admin_sort_image" src="' . $image_url . '" width="30px" height="30px" alt="" />';
}
?>
<span class="mtheme_admin_sort_title"><?php
the_title();
?>
</span>
<?php
if ($portfolio_cats) {
?>
<span class="mtheme_admin_sort_categories"><?php
foreach ($portfolio_cats as $taxonomy) {
echo ' | ' . $taxonomy->name;
}
?>
</span>
<?php
}
?>
</div>
</li>
<?php
}
?>
</div><!-- End div#wrap //-->
<?php
}
示例6: lightbox_func
/**
* Shortcode function for Lightbox2
*
* @see [lightbox name="gallery" post="1"]
* @param $atts
* @param null $content
*/
function lightbox_func($atts, $content = null)
{
$a = shortcode_atts(array('name' => 'lightbox', 'class' => 'lightbox'), $atts);
wp_register_script('lightbox', YONK_URL . 'assets/js/lightbox.min.js', false, '2.8.2');
wp_enqueue_script('lightbox');
wp_register_style('lightbox', YONK_URL . 'assets/css/lightbox.min.css', false, '2.8.2', 'all');
wp_enqueue_style('lightbox');
if (!isset($a['post'])) {
global $post;
$p = $post;
} else {
$p = get_post(intval($a['post']));
}
$image_urls = explode('~~~', Yonk_Frontend::get_meta('gallery_attachments', $p));
ob_start();
?>
<div style="position:relative;">
<div id="<?php
echo $a['name'];
?>
" class="<?php
echo $a['class'];
?>
">
<?php
foreach ($image_urls as $url) {
$attachment_id = get_attachment_id($url);
$attachment = get_post($attachment_id);
?>
<a href="<?php
echo $url;
?>
" data-lightbox="<?php
echo $a['name'];
?>
" data-title="<?php
echo $attachment->post_excerpt;
?>
">
<img src="<?php
echo wp_get_attachment_thumb_url($attachment_id);
?>
" alt="<?php
echo $attachment->post_title;
?>
" />
</a>
<?php
}
?>
</div>
</div>
<?php
return ob_get_clean();
}
示例7: qeui_add_thumbnail_callback
function qeui_add_thumbnail_callback()
{
$thumb_id = $_POST['thumb_id'];
$post_id = $_POST['post_id'];
$thumbnail = wp_get_attachment_thumb_url($thumb_id);
update_post_meta($post_id, '_thumbnail_id', $thumb_id);
echo json_encode(array('post_id' => $post_id, 'img_url' => $thumbnail, 'thumb_id' => $thumb_id));
die;
}
示例8: getImages
public static function getImages($brochure)
{
$images = array();
foreach ($brochure['image_gallery'] as $image) {
$row['image_url'] = wp_get_attachment_url($image);
$row['thumbnail_url'] = wp_get_attachment_thumb_url($image);
$row['thumbnail_image'] = wp_get_attachment_image($image);
$images[] = $row;
}
return $images;
}
示例9: get_avatar
/**
* Get an customer avatar
*
* @param integer avatar size in pixels
*
* @return string image with HTML tag
*/
public function get_avatar($size = 32)
{
if ($this->id) {
$user_photo_id = $this->get_meta('photo_id', true);
if (!empty($user_photo_id)) {
$image = wp_get_attachment_thumb_url($user_photo_id);
return sprintf('<img src="%1$s" alt="" class="avatar avatar-%2$s photo" height="auto" width="%2$s" />', $image, $size);
}
}
return get_avatar($this->email, $size);
}
示例10: echo_first_image
function echo_first_image($postID)
{
$args = array('numberposts' => 1, 'order' => 'ASC', 'post_mime_type' => 'image', 'post_parent' => $postID, 'post_status' => null, 'post_type' => 'attachment');
$attachments = get_children($args);
if ($attachments) {
foreach ($attachments as $attachment) {
$image_attributes = wp_get_attachment_image_src($attachment->ID, 'thumbnail') ? wp_get_attachment_image_src($attachment->ID, 'thumbnail') : wp_get_attachment_image_src($attachment->ID, 'full');
echo '<img src="' . wp_get_attachment_thumb_url($attachment->ID) . '">';
}
}
}
示例11: add_post_meta
add_post_meta($post_ID, 'mgop_media_value', $data, true) or update_post_meta($post_ID, 'mgop_media_value', $data);
}
public function mb_callback($post, $box)
{
$value = get_post_meta($post->ID, 'mgop_media_value', true);
$value = isset($value[$box['id']]) ? $value[$box['id']] : array();
wp_nonce_field(plugin_basename(__FILE__), 'mgop_noncename');
?>
<a href="#" class="mgop_add" data-for="<?php
echo $box['id'];
?>
" title="<?php
echo $box['title'];
?>
">Add Image</a>
<ul id="mgop_<?php
echo $box['id'];
?>
" class="mgop-wrapper-sortable">
<?php
if (is_array($value) && count($value)) {
foreach ($value as $attc_id) {
$url = wp_get_attachment_thumb_url($attc_id);
?>
<li class="mgop_thumnails" title="Drag and drop to sort the item"><div><span class="mgop-movable"></span><a href="#" class="mgop_remove_item" title="Click to delete this item"><span>delete</span></a><img src="<?php
echo $url;
?>
"><input type="hidden" name="mgop_media[<?php
echo $box['id'];
?>
][]" value="<?php
echo $attc_id;
?>
" /></div></li>
<?php
}
}
?>
</ul>
<div class="mgop-detail" style="border-top: 1px solid #ccc;">
<ul>
<li><label>Gallery Slug</label>: <code><?php
echo $box['args']['slug'];
?>
</code></li>
<li><label>Output Location</label>: <?php
echo $this->positions[$box['args']['position']];
?>
</li>
示例12: erp_crm_get_avatar
/**
* Get an avatar avatar
*
* @param integer avatar size in pixels
*
* @return string image with HTML tag
*/
function erp_crm_get_avatar($id, $size = 32, $user = false)
{
if ($id) {
if ($user) {
return get_avatar($id, $size);
}
$user_photo_id = erp_people_get_meta($id, 'photo_id', true);
if (!empty($user_photo_id)) {
$image = wp_get_attachment_thumb_url($user_photo_id);
return sprintf('<img src="%1$s" alt="" class="avatar avatar-%2$s photo" height="auto" width="%2$s" />', $image, $size);
}
}
return get_avatar($id, $size);
}
示例13: uz_ui_load_more_images
function uz_ui_load_more_images()
{
global $wpdb;
$offset = esc_sql($_GET['offset']);
$offset = $offset ? $offset * 25 : 0;
$images = $wpdb->get_results(" SELECT ID FROM {$wpdb->posts} WHERE post_type = 'attachment' AND post_mime_type LIKE 'image%' ORDER BY post_date DESC LIMIT {$offset},25 ");
foreach ($images as $key => $image) {
$images[$key]->url = wp_get_attachment_thumb_url($image->ID);
}
if (count($images) > 0) {
echo json_encode($images);
}
die;
}
示例14: edit_automobile_category_fields
function edit_automobile_category_fields($term)
{
global $autoMobile;
$automobile_category_extra_fields = get_option('automobile_category_images');
$thumbnail_id = absint($automobile_category_extra_fields[$term->term_id]['automobile_category_images']);
if ($thumbnail_id) {
$image = wp_get_attachment_thumb_url($thumbnail_id);
} else {
$image = $autoMobile->auto_mobile_default_image();
}
?>
<tr class="form-field">
<th scope="row" valign="top"><label><?php
echo _e('Thumbnail', 'automobileoptions');
?>
</label></th>
<td>
<div id="automobile_product_category_thumbnail" style="float: left; margin-right: 10px;"><img src="<?php
echo esc_url($image);
?>
" width="60px" height="60px" /></div>
<div style="line-height: 60px;">
<input type="hidden" id="automobile_product_category_thumbnail_id" name="automobile_product_category_thumbnail_id" value="<?php
echo $thumbnail_id;
?>
" />
<button type="button" class="upload_image_button button"><?php
echo _e('Upload/Add image', 'automobileoptions');
?>
</button>
<button type="button" class="remove_image_button button"><?php
echo _e('Remove image', 'automobileoptions');
?>
</button>
</div>
<script type="text/javascript">
// Only show the "remove image" button when needed
if ( '0' === jQuery( '#automobile_product_category_thumbnail_id' ).val() ) {
jQuery( '.remove_image_button' ).hide();
}
</script>
<div class="clear"></div>
</td>
</tr>
<?php
}
示例15: widget
/**
* Outputs the content of the widget
*
* @param array $args
* @param array $instance
*/
public function widget($args, $instance) {
$title = apply_filters('widget_title', $instance['title']);
$imgWidth = apply_filters('widget_img_width', $instance['img_width']);
$imgHight = apply_filters('widget_img_height', $instance['img_height']);
$gallery_images = apply_filters('gallery_images', $instance['gallery_images']);
$gallery_images = !empty($gallery_images) ? maybe_unserialize($gallery_images) : false;
echo $args['before_widget'];
if (!empty($title)) {
echo $args['before_title'] . $title . $args['after_title'];
}
if (!empty($gallery_images)) {
$carousel = '<div class="gallery-popup-wrap">';
$carousel .= sprintf('<div id="gallery-%s" class="popup-gallery">', $args['widget_id']);
foreach ($gallery_images as $attachment_id) {
$image = wp_get_attachment_image_src($attachment_id, 'full');
$thumb_url = wp_get_attachment_thumb_url($attachment_id);
$carousel .= sprintf('<div class="gallery-item"><a href="%1$s"><img src="%2$s" alt="gallery-image" width="%3$s" height="%4$s" alt="Gallery Image"></a></div>', $image[0], $thumb_url, $imgWidth, $imgHight);
}
$carousel .= '</div>';
$carousel .= '</div>';
$nav = ($carousel_nav == 'yes') ? 'true' : 'false';
$dot = ($carousel_dot == 'yes') ? 'true' : 'false';
$autoplay = ($carousel_autoplay == 'yes') ? 'true' : 'false';
$item = !empty($image_display) ? $image_display : 1;
echo $carousel;
?>
<script type="text/javascript">
jQuery(document).ready(function () {
if (typeof jQuery.fn.magnificPopup !== 'undefined') {
jQuery('.popup-gallery').magnificPopup({
type: 'image',
delegate: 'a',
gallery: {
enabled: true
}
});
}
console.log(typeof jQuery.fn.magnificPopup);
});
</script>
<?php
}
echo '<div class="clearfix"></div>';
echo $args['after_widget'];
}