• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP wp_get_attachment_image函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: display_media

 public function display_media($location, $fallback = true, $fallbackhome = false)
 {
     global $post;
     ob_start();
     $media = $this->query_attachments($post->ID, $location);
     if (!$media->have_posts() && $fallback == true) {
         $media = $this->query_attachments($post->post_parent, $location);
     }
     if (!$media->have_posts() && $fallbackhome == true) {
         $frontpage_id = get_option('page_on_front');
         $media = $this->query_attachments($frontpage_id, $location);
     }
     if ($media->have_posts()) {
         while ($media->have_posts()) {
             $media->the_post();
             $media_info = get_post_custom(get_the_ID());
             if (isset($media_info['image_link']) && $media_info['image_link'][0]) {
                 echo '<a href="' . $media_info['image_link'][0] . '">';
             }
             echo wp_get_attachment_image(get_the_ID(), 'full');
             if (isset($media_info['image_link']) && $media_info['image_link'][0]) {
                 echo '</a>';
             }
         }
         wp_reset_postdata();
     } else {
         return false;
     }
     return ob_get_clean();
 }
开发者ID:jemjabella,项目名称:media-locations,代码行数:30,代码来源:class.frontend.php


示例2: my_custom_columns

function my_custom_columns($column)
{
    global $post;
    // Bildstorlek
    $width = (int) 200;
    $height = (int) 125;
    if ('ID' == $column) {
        echo $post->ID;
    } elseif ('thumbnail' == $column) {
        // thumbnail of WP 2.9
        $thumbnail_id = get_post_meta($post->ID, '_thumbnail_id', true);
        // image from gallery
        $attachments = get_children(array('post_parent' => $post_id, 'post_type' => 'attachment', 'post_mime_type' => 'image'));
        if ($thumbnail_id) {
            $thumb = wp_get_attachment_image($thumbnail_id, array($width, $height), true);
        } elseif ($attachments) {
            foreach ($attachments as $attachment_id => $attachment) {
                $thumb = wp_get_attachment_image($attachment_id, array($width, $height), true);
            }
        }
        if (isset($thumb) && $thumb) {
            echo $thumb;
        } else {
            echo __('None');
        }
    } elseif ('description' == $column) {
        echo $post->post_content;
    }
}
开发者ID:Jonatan,项目名称:makthavare,代码行数:29,代码来源:makthavare.php


示例3: wpthumb_img_shortcode

function wpthumb_img_shortcode($args)
{
    $args_attrs = array('class', 'alt');
    $attrs = array();
    foreach ($args_attrs as $att) {
        if (isset($args[$att])) {
            $attrs[$att] = $args[$att];
            unset($args[$att]);
        }
    }
    if (is_numeric($args[0])) {
        $attachment_id = $args[0];
        unset($args[0]);
        return wp_get_attachment_image($attachment_id, $args, false, $attrs);
    } else {
        if (!empty($args)) {
            $url = esc_url($args[0]);
            unset($args[0]);
            $image = wpthumb($url, $args);
            list($width, $height) = getimagesize($image);
            $attr = '';
            foreach ($attrs as $a => $value) {
                $attr .= ' ' . $a . '="' . esc_attr($value) . '"';
            }
            return '<img src="' . $image . '" width="' . $width . '" height="' . $height . '"' . $attr . ' />';
        }
    }
}
开发者ID:RA2WP,项目名称:RA2WP,代码行数:28,代码来源:wpthumb.shortcodes.php


示例4: 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&amp;action=ya_quickviewproduct&amp;post_id=' . $post->ID . '&amp;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;
    }
}
开发者ID:junibrosas,项目名称:shoppingyourway,代码行数:32,代码来源:woocommerce-hook.php


示例5: thb_image

function thb_image($atts, $content = null)
{
    extract(shortcode_atts(array('image' => '', 'target_blank' => false, 'img_size' => 'thumbnail', 'img_link' => '', 'img_link_target' => '', 'alignment' => '', 'lightbox' => '', 'size' => 'small', 'animation' => false), $atts));
    $img_id = preg_replace('/[^\\d]/', '', $image);
    //$img = wpb_getImageBySize(array( 'attach_id' => $img_id, 'thumb_size' => $img_size, 'class' => $animation ));
    $img = wp_get_attachment_image($img_id, $img_size, false, array('class' => $animation . ' ' . $alignment, 'alt' => trim(strip_tags(get_post_meta($img_id, '_wp_attachment_image_alt', true)))));
    if ($img == NULL) {
        $img = '<img src="http://placekitten.com/g/400/300" />';
    }
    $link_to = $c_lightbox = '';
    if ($lightbox == true) {
        $link_to = wp_get_attachment_image_src($img_id, 'large');
        $link_to = $link_to[0];
        $c_lightbox = ' rel="magnific"';
    } else {
        if (!empty($img_link)) {
            $link_to = $img_link;
        }
    }
    if (!empty($link_to) && !preg_match('/^(https?\\:\\/\\/|\\/\\/)/', $link_to)) {
        $link_to = 'http://' . $link_to;
    }
    $out = !empty($link_to) ? '<a ' . $c_lightbox . ' href="' . $link_to . '"' . ($target_blank ? ' target="_blank"' : '') . '>' . $img . '</a>' : $img;
    return $out;
}
开发者ID:ConceptHaus,项目名称:beckery,代码行数:25,代码来源:thb_image.php


示例6: element

 function element()
 {
     $style = $this->opt('style') ? $this->opt('style') : '';
     $image = $this->opt('image') ? $this->opt('image') : '';
     $click_action = $this->opt('click_action') ? $this->opt('click_action') : '';
     $image_alignment = $this->opt('image_alignment') ? $this->opt('image_alignment') : '';
     //** Appear animation
     $appear_delay = $this->opt('appear_delay') ? $this->opt('appear_delay') : '0';
     $appear = $this->opt('appear_animation') ? $this->opt('appear_animation') : '';
     if (!empty($appear)) {
         $appear = 'data-appear="fade-in" data-appear-direction="' . $appear . '" data-appear-delay="' . $appear_delay . '"';
     }
     if (empty($image)) {
         echo '<div class="zn-pb-notification">Please configure the element and add an image.</div>';
         return;
     }
     //$link = $this->opt('link');
     //$link_extracted = !empty( $link ) ? zn_extract_link( $this->opt('link') , '' ) : '';
     $link_extracted = zn_extract_link($this->opt('link'));
     if ($click_action === 'popup') {
         $image_src = wp_get_attachment_image($image, 'full', false, array('class' => 'img-responsive animate magPopupImg ' . $image_alignment . '', 'data-mfp-src' => wp_get_attachment_url($image)));
     } else {
         if ($click_action === 'link') {
             $image_src = $link_extracted['start'] . wp_get_attachment_image($image, 'full', false, array('class' => 'img-responsive animate ' . $image_alignment . '')) . $link_extracted['end'];
         } else {
             $image_src = wp_get_attachment_image($image, 'full', false, array('class' => 'img-responsive ' . $image_alignment . ''));
         }
     }
     echo '<div class="znImageContainer clearfix ' . $this->data['uid'] . '" ' . $appear . '>';
     //echo '<img alt="Image" src="'.$image.'" class="img-responsive animate">';
     echo '<div class="znImgSubcontainer ' . (empty($click_action) ? '' : 'scaleRotateImg') . '">';
     echo $image_src;
     echo '</div>';
     echo '</div>';
 }
开发者ID:fjbeteiligung,项目名称:development,代码行数:35,代码来源:image.php


示例7: tb_ad_featured_thumbnail

 function tb_ad_featured_thumbnail()
 {
     global $post;
     // go see if any images are associated with the ad
     $image_id = cp_get_featured_image_id($post->ID);
     // set the class based on if the hover preview option is set to "yes"
     if (get_option('cp_ad_image_preview') == 'yes') {
         $prevclass = 'preview';
     } else {
         $prevclass = 'nopreview';
     }
     if ($image_id > 0) {
         // get 50x50 v3.0.5+ image size
         $adthumbarray = wp_get_attachment_image($image_id, 'ad-small');
         // grab the large image for onhover preview
         $adlargearray = wp_get_attachment_image_src($image_id, 'large');
         $img_large_url_raw = $adlargearray[0];
         // must be a v3.0.5+ created ad
         if ($adthumbarray) {
             echo '<a href="' . get_permalink() . '" title="' . the_title_attribute('echo=0') . '" class="' . $prevclass . '" data-rel="' . $img_large_url_raw . '">' . $adthumbarray . '</a>';
             // maybe a v3.0 legacy ad
         } else {
             $adthumblegarray = wp_get_attachment_image_src($image_id, 'ad-small');
             $img_thumbleg_url_raw = $adthumblegarray[0];
             echo '<a href="' . get_permalink() . '" title="' . the_title_attribute('echo=0') . '" class="' . $prevclass . '" data-rel="' . $img_large_url_raw . '">' . $adthumblegarray . '</a>';
         }
         // no image so return the placeholder thumbnail
     } else {
         echo '<a href="' . get_permalink() . '" title="' . the_title_attribute('echo=0') . '"><img class="attachment-sidebar-thumbnail" alt="" title="" src="' . get_stylesheet_directory_uri() . '/images/no-thumb-100.jpg" /></a>';
     }
 }
开发者ID:joslec9,项目名称:Job-posting-page,代码行数:31,代码来源:functions.php


示例8: theme2_gallery

function theme2_gallery($attr, $text = '')
{
    // var_dump($attr);
    $img_src = explode(',', $attr['ids']);
    // print_r($img_src);
    $pattern = '#(width|height)="\\d+"#';
    $return = '<ul id="slide_2" class="slidik">';
    $i = 1;
    foreach ($img_src as $key) {
        //получаем хтмл картинки
        $img_url = wp_get_attachment_image($key, 'full');
        // вырезаем атрибуты ширины и высоты
        $img_url = preg_replace($pattern, '', $img_url);
        if ($i == 1) {
            $return .= '<li class="show">' . $img_url . '</li>';
        } else {
            $return .= '<li>' . $img_url . '</li>';
        }
        $i++;
    }
    $return .= '<a data-slidik="slide_2" class="next" href="#">Next</a>
            <a data-slidik="slide_2" class="prev" href="#">Prev</a>
            <div class="captionWrap"><div data-slidik="slide_2" class="caption"></div></div>
            <div class="portfolio-close"><a href="#"></a></div>
        </ul>';
    echo "{$return}";
}
开发者ID:ipixby,项目名称:wp2,代码行数:27,代码来源:functions.php


示例9: mm_posts_output_custom_post_image_simple_image_content

/**
 * Custom Image Output for Simple Image & Content template.
 */
function mm_posts_output_custom_post_image_simple_image_content($post, $context, $args)
{
    $custom_output = apply_filters('mm_posts_post_image', '', $post, $context, $args);
    if ('' !== $custom_output) {
        echo $custom_output;
        return;
    }
    // Default to using the 'post-thumbnail' size.
    if ('' !== $args['featured_image_size']) {
        $image_size = esc_attr($args['featured_image_size']);
    } else {
        $image_size = 'post-thumbnail';
    }
    // Check for existing featured image
    if (has_post_thumbnail($post->ID)) {
        $image_tag = get_the_post_thumbnail($post->ID, $image_size);
    } else {
        $fallback_image = $args['fallback_image'];
        // Support the fallback image
        if (is_numeric($fallback_image)) {
            $image_tag = wp_get_attachment_image($fallback_image, $image_size);
        }
    }
    // Output image with/without link
    if (mm_true_or_false($args['link_title'])) {
        printf('<div class="entry-image"><a href="%s">%s</a></div>', get_permalink($post->ID), $image_tag);
    } else {
        printf('<div class="entry-image">%s</div>', $image_tag);
    }
}
开发者ID:jgonzo127,项目名称:mm-components,代码行数:33,代码来源:simple-image-content.php


示例10: theme2_gallery

/**
*	shortcode_gallery
**/
function theme2_gallery($attr, $text = '')
{
    // получить массив ID картинок
    $img_src = explode(',', $attr['ids']);
    // шаблон удаления атрибутов width/height
    $pattern = '#(width|height)="\\d+"#';
    $return = '<ul id="slide_2" class="slidik">';
    //счетчик
    $i = 1;
    foreach ($img_src as $item) {
        $image_url = wp_get_attachment_image($item, 'full');
        //delete width and height
        $image_url = preg_replace($pattern, "", $image_url);
        //формируем вывод
        if ($i == 1) {
            $return .= '<li class="show">' . $image_url . '</li>';
        } else {
            $return .= '<li>' . $image_url . '</li>';
        }
        $i++;
    }
    $return .= '<a data-slidik="slide_2" class="next" href="#">Next</a>
			<a data-slidik="slide_2" class="prev" href="#">Prev</a>
			<div class="captionWrap"><div data-slidik="slide_2" class="caption"></div></div>
			<div class="portfolio-close"><a href="portfolio.html"></a></div>			
		</ul>';
    echo $return;
}
开发者ID:Aliot26,项目名称:WP,代码行数:31,代码来源:functions.php


示例11: get_markup

 public function get_markup()
 {
     if (empty($this->attachment_id)) {
         $this->markup = '';
     }
     $this->markup = wp_get_attachment_image($this->attachment_id, $this->image_size, $this->icon, $this->attributes);
 }
开发者ID:Clark-Nikdel-Powell,项目名称:Pattern-Library,代码行数:7,代码来源:image.php


示例12: ocwssl_wp_post_thumbnail_html

function ocwssl_wp_post_thumbnail_html($thumbnail_id = null, $post = null)
{
    global $content_width, $_wp_additional_image_sizes;
    $post = get_post($post);
    $post_type_object = get_post_type_object($post->post_type);
    $set_thumbnail_link = '<p class="hide-if-no-js"><a title="%s" href="%s" id="set-post-thumbnail" class="thickbox">%s</a></p>';
    $upload_iframe_src = get_upload_iframe_src('image', $post->ID);
    $content = sprintf($set_thumbnail_link, esc_attr($post_type_object->labels->set_featured_image), esc_url($upload_iframe_src), esc_html($post_type_object->labels->set_featured_image));
    if ($thumbnail_id && get_post($thumbnail_id)) {
        $old_content_width = $content_width;
        $content_width = 1000;
        if (!isset($_wp_additional_image_sizes['full'])) {
            // use 'full' for system defined fullsize image OR use our custom image size instead of 'post-thumbnail'
            $thumbnail_html = wp_get_attachment_image($thumbnail_id, array($content_width, $content_width));
        } else {
            $thumbnail_html = wp_get_attachment_image($thumbnail_id, 'full');
        }
        // use 'full' for system defined fullsize image OR use our custom image size instead of 'post-thumbnail'
        if (!empty($thumbnail_html)) {
            $ajax_nonce = wp_create_nonce('set_post_thumbnail-' . $post->ID);
            $content = sprintf($set_thumbnail_link, esc_attr($post_type_object->labels->set_featured_image), esc_url($upload_iframe_src), $thumbnail_html);
            $content .= '<p class="hide-if-no-js"><a href="#" id="remove-post-thumbnail" onclick="WPRemoveThumbnail(\'' . $ajax_nonce . '\');return false;">' . esc_html($post_type_object->labels->remove_featured_image) . '</a></p>';
        }
        $content_width = $old_content_width;
    }
    /**
     * Filter the admin post thumbnail HTML markup to return.
     *
     * @since 2.9.0
     *
     * @param string $content Admin post thumbnail HTML markup.
     * @param int    $post_id Post ID.
     */
    return apply_filters('admin_post_thumbnail_html', $content, $post->ID);
}
开发者ID:pftaylor61,项目名称:ocws-slider,代码行数:35,代码来源:ocws-slider.php


示例13: bb_get_attachment_id_from_url

function bb_get_attachment_id_from_url($attachment_url = '', $size = null)
{
    global $wpdb;
    $attachment_id = false;
    // If there is no url, return.
    if ('' == $attachment_url) {
        return;
    }
    // Get the upload directory paths
    $upload_dir_paths = wp_upload_dir();
    // Make sure the upload path base directory exists in the attachment URL, to verify that we're working with a media library image
    if (false !== strpos($attachment_url, $upload_dir_paths['baseurl'])) {
        // If this is the URL of an auto-generated thumbnail, get the URL of the original image
        $attachment_url = preg_replace('/-\\d+x\\d+(?=\\.(jpg|jpeg|png|gif)$)/i', '', $attachment_url);
        // Remove the upload path base directory from the attachment URL
        $attachment_url = str_replace($upload_dir_paths['baseurl'] . '/', '', $attachment_url);
        //$attachment_url = strstr( $attachment_url, '-', true );
        // Finally, run a custom database query to get the attachment ID from the modified attachment URL
        $attachment_id = $wpdb->get_var($wpdb->prepare("SELECT wposts.ID FROM {$wpdb->posts} wposts, {$wpdb->postmeta} wpostmeta WHERE wposts.ID = wpostmeta.post_id AND wpostmeta.meta_key = '_wp_attached_file' AND wpostmeta.meta_value = '%s' AND wposts.post_type = 'attachment'", $attachment_url));
    }
    //prar("Size: $size");
    if ($size) {
        $image = wp_get_attachment_image($attachment_id, $size);
        //prar($image);
        return $image;
    } else {
        return $attachment_id;
    }
}
开发者ID:perkster,项目名称:bear-bones,代码行数:29,代码来源:page.php


示例14: widget

    function widget($args, $instance)
    {
        // Widget output
        $args = array('numberposts' => 1, 'offset' => 0, 'category' => 0, 'orderby' => 'post_date', 'order' => 'DESC', 'post_status' => 'publish', 'suppress_filters' => true);
        $recent_posts = wp_get_recent_posts($args, ARRAY_A);
        $thumb_url = wp_get_attachment_image(get_post_thumbnail_id($recent_posts[0]['ID']), array(194, 220), true);
        ?>

        <div class="blog">
            <div class="blog-image">
                <img src="<?php 
        echo get_template_directory_uri();
        ?>
/img/blog.png"/>
            </div>
            <div class="image">
                <?php 
        echo $thumb_url;
        ?>

            </div>
            <div class="content">
                <?php 
        echo $recent_posts[0]['post_excerpt'];
        ?>

                <a href="<?php 
        echo get_permalink($recent_posts[0]['ID']);
        ?>
">Read more</a>
            </div>
        </div>
        <?php 
    }
开发者ID:rongandat,项目名称:sallumeh,代码行数:34,代码来源:lastestBlog.php


示例15: as_tours_cats_custom_field

function as_tours_cats_custom_field()
{
    $t_id = $_GET['tag_ID'];
    $images = get_option('as_tour_cats_featured_images');
    if ($images === FALSE) {
        $image = array();
    }
    $image = isset($images[$t_id]) ? $images[$t_id] : '';
    ?>
    <table class="form-table">
        <tr class="form-field">
            <th valign="top" scope="row">
                <label>Featured Image</label>
            </th>
            <td>
                <input id="as-tour-cats-featured-image" type="hidden" name="as_tour_cats_featured_image" readonly="readonly" value="<?php 
    echo $image;
    ?>
" />
                <input id="as-tour-cats-remove-image" class="button" type="button" value="Remove image" />
                <input id="as-tour-cats-change-image" class="button" type="button" value="Change image" />
                <div id="as-tour-cats-thumbnail"><?php 
    if (!empty($image)) {
        echo wp_get_attachment_image($image);
    }
    ?>
</div>
                <p class="description">Set a featured image for all the post of this category without a featured image.</p>
            </td>
        </tr>
    </table>
    <?php 
}
开发者ID:bibiangel1989,项目名称:vespatour,代码行数:33,代码来源:tours-categories.php


示例16: distinctpress_get_image

/** DistinctPress Get Image*/
function distinctpress_get_image($args = array())
{
    global $post;
    /** Arguments */
    $defaults = array('format' => 'html', 'size' => 'full', 'num' => 0, 'attr' => '');
    $args = wp_parse_args($args, $defaults);
    /** WordPress built-in method */
    if (has_post_thumbnail() && $args['num'] === 0) {
        $id = get_post_thumbnail_id();
        $html = wp_get_attachment_image($id, $args['size'], false, $args['attr']);
        list($url) = wp_get_attachment_image_src($id, $args['size'], false, $args['attr']);
    } else {
        $id = distinctpress_get_image_id($args['num']);
        $html = wp_get_attachment_image($id, $args['size'], false, $args['attr']);
        list($url) = wp_get_attachment_image_src($id, $args['size'], false, $args['attr']);
    }
    /** Source path, relative to the root */
    $src = str_replace(home_url(), '', $url);
    /** Output Logic */
    if (strtolower($args['format']) == 'html') {
        $output = $html;
    } else {
        if (strtolower($args['format']) == 'url') {
            $output = $url;
        } else {
            $output = $src;
        }
    }
    /** return FALSE if $url is blank */
    if (empty($url)) {
        $output = FALSE;
    }
    /** return output */
    return $output;
}
开发者ID:phatboyg,项目名称:phatboyg.github.io,代码行数:36,代码来源:featured-image.php


示例17: photoline_modified_post_gallery

function photoline_modified_post_gallery($output, $attr)
{
    global $post;
    static $instance = 0;
    $instance++;
    //disable all filter
    if (empty($attr['type']) || $attr['type'] != 'slider') {
        return;
    }
    if (isset($attr['orderby'])) {
        $attr['orderby'] = sanitize_sql_orderby($attr['orderby']);
        if (!$attr['orderby']) {
            unset($attr['orderby']);
        }
    }
    extract(shortcode_atts(array('order' => 'ASC', 'orderby' => 'menu_order ID', 'id' => $post->ID, 'size' => 'photoline-featured', 'include' => '', 'exclude' => ''), $attr));
    $id = intval($id);
    if ('RAND' == $order) {
        $orderby = 'none';
    }
    if (!empty($include)) {
        $include = preg_replace('/[^0-9,]+/', '', $include);
        $_attachments = get_posts(array('include' => $include, 'post_status' => 'inherit', 'post_type' => 'attachment', 'post_mime_type' => 'image', 'order' => $order, 'orderby' => $orderby));
        $attachments = array();
        foreach ($_attachments as $key => $val) {
            $attachments[$val->ID] = $_attachments[$key];
        }
    } elseif (!empty($exclude)) {
        $exclude = preg_replace('/[^0-9,]+/', '', $exclude);
        $attachments = get_children(array('post_parent' => $id, 'exclude' => $exclude, 'post_status' => 'inherit', 'post_type' => 'attachment', 'post_mime_type' => 'image', 'order' => $order, 'orderby' => $orderby));
    } else {
        $attachments = get_children(array('post_parent' => $id, 'post_status' => 'inherit', 'post_type' => 'attachment', 'post_mime_type' => 'image', 'order' => $order, 'orderby' => $orderby));
    }
    if (empty($attachments)) {
        return '';
    }
    if (is_feed()) {
        $output = "\n";
        foreach ($attachments as $att_id => $attachment) {
            $output .= wp_get_attachment_link($att_id, $size, true) . "\n";
        }
        return $output;
    }
    $selector = "gallery-{$instance}";
    $size_class = sanitize_html_class($size);
    $gallery_div = "<div id='{$selector}' class='gallery galleryid-{$id} gallery-size-{$size_class} flexslider'>";
    $output = apply_filters('gallery_style', $gallery_div);
    $output .= '<ul class="slides">';
    $i = 0;
    foreach ($attachments as $id => $attachment) {
        $caption = !empty($attachment->post_excerpt) ? '<p class="flex-caption wp-caption-text gallery-caption">' . wptexturize($attachment->post_excerpt) . '</p>' : '';
        $image = wp_get_attachment_image($id, $size);
        $output .= '<li>';
        $output .= $image;
        $output .= $caption;
        $output .= '</li>';
    }
    $output .= "\r\n            </ul><!-- .slides -->\r\n        </div>\n";
    return $output;
}
开发者ID:AlexanderDolgan,项目名称:ojahuri,代码行数:60,代码来源:gallery-layout.php


示例18: _get_post_thumbnail

 /**
  * Get the thumbnail image for a post's image
  * 
  * Attempts to find the URL for the thumbnail size of an image attached to a Post
  * 
  * @param int $post_id The ID of the WordPress Post
  * @param string $image_url The URL of the image to get a thumbnail for
  * 
  * @global $wpdb
  * 
  * @uses current_theme_supports()
  * @uses get_the_post_thumbnail()
  * @uses wpdb::prepare()
  * @uses wpdb::get_row()
  * @uses wp_get_attachment_image()
  * @uses wp_upload_dir()
  * 
  * @return string
  */
 private function _get_post_thumbnail($post_id, $image_url)
 {
     global $wpdb;
     $thumbnail_src = $image_url;
     $thumbnail_html = "";
     // Use the post thumbnail if possible
     if (current_theme_supports('post-thumbnails')) {
         $thumbnail_html = get_the_post_thumbnail($post_id, 'thumbnail');
     }
     // Process for a thumbnail version of the background image
     $url_parts = parse_url($image_url);
     // Get array of URL parts of the image
     $wp_upload_dir = wp_upload_dir();
     // Get array of URL parts of the upload directory
     $relative_upload_base = str_replace(ABSPATH, "", str_replace($wp_upload_dir['subdir'], "", $wp_upload_dir['path']));
     if (isset($url_parts['host']) && $url_parts['host'] == $_SERVER['HTTP_HOST'] && strpos($url_parts['path'], "/" . $relative_upload_base) !== false) {
         $image_url_original = preg_replace("/\\-[0-9]+x[0-9]+\\.(jpeg|jpg|gif|png|bmp)\$/", ".\$1", $image_url);
         $post = $wpdb->get_row($wpdb->prepare("SELECT * FROM {$wpdb->posts} WHERE guid = %s", $image_url_original));
         if (!empty($post)) {
             $thumbnail_html = wp_get_attachment_image($post->ID, 'thumbnail');
         }
     }
     if (!empty($thumbnail_html)) {
         $matches = array();
         preg_match("/ src\\=\"([^\"]+)\"/", $thumbnail_html, $matches);
         if (count($matches) > 1) {
             $thumbnail_src = $matches[1];
         }
     }
     return $thumbnail_src;
 }
开发者ID:danaiser,项目名称:hollandLawns,代码行数:50,代码来源:source.php


示例19: editor_element

 /**
  * Editor Element - this function defines the visual appearance of an element on the AviaBuilder Canvas
  * Most common usage is to define some markup in the $params['innerHtml'] which is then inserted into the drag and drop container
  * Less often used: $params['data'] to add data attributes, $params['class'] to modify the className
  *
  *
  * @param array $params this array holds the default values for $content and $args.
  * @return $params the return array usually holds an innerHtml key that holds item specific markup.
  */
 function editor_element($params)
 {
     $img = "";
     $template = $this->update_template("src", "<img src='{{src}}' alt=''/>");
     if (!empty($params['args']['attachment']) && !empty($params['args']['attachment_size'])) {
         $img = wp_get_attachment_image($params['args']['attachment'], $params['args']['attachment_size']);
     } else {
         if (isset($params['args']['src']) && is_numeric($params['args']['src'])) {
             $img = wp_get_attachment_image($params['args']['src'], 'large');
         } else {
             if (!empty($params['args']['src'])) {
                 $img = "<img src='" . $params['args']['src'] . "' alt=''  />";
             }
         }
     }
     $params['innerHtml'] = "<div class='avia_image avia_hotspot_image avia_image_style '>";
     $params['innerHtml'] .= "<div class='avia_image_container avia-align-center ' {$template}>{$img}</div>";
     $params['innerHtml'] .= "<div class='avia-flex-element'>";
     $params['innerHtml'] .= __('This element will stretch across the whole screen by default.', 'avia_framework') . "<br/>";
     $params['innerHtml'] .= __('If you put it inside a color section or column it will only take up the available space', 'avia_framework');
     $params['innerHtml'] .= "\t<div class='avia-flex-element-2nd'>" . __('Currently:', 'avia_framework');
     $params['innerHtml'] .= "\t<span class='avia-flex-element-stretched'>&laquo; " . __('Stretch fullwidth', 'avia_framework') . " &raquo;</span>";
     $params['innerHtml'] .= "\t<span class='avia-flex-element-content'>| " . __('Adjust to content width', 'avia_framework') . " |</span>";
     $params['innerHtml'] .= "\t</div>";
     $params['innerHtml'] .= "\t<span class='av_hotspot_image_caption button button-primary button-large'>" . __('Image with Hotspots - Click to insert image and hotspots', 'avia_framework') . "</span>";
     $params['innerHtml'] .= "</div>";
     $params['innerHtml'] .= "</div>";
     $params['class'] = "";
     return $params;
 }
开发者ID:erikdukker,项目名称:medisom,代码行数:39,代码来源:image_hotspots.php


示例20: add_metabox_content

 /**
  * Callback: show the metabox content
  *
  * @param $post
  */
 public function add_metabox_content($post)
 {
     wp_nonce_field('apg_metabox_nonce', 'apg_metabox_nonce');
     $viewer = new Viewer();
     $photos = $viewer->get_photos($post->ID);
     if (count($photos) >= 1) {
         $photo_hidden = array();
         echo '<div style="width: 95%; padding: 0;">';
         echo '<ul id="apg-sortable" class="apg-sortable">';
         foreach ($photos as $photo) {
             if (empty($photo['ID'])) {
                 continue;
             }
             echo '<li id="apg-photo-' . esc_attr($photo['ID']) . '" data-apgid="' . esc_attr($photo['ID']) . '" style="float: left;width: 80px; height: 80px; display: block; position:relative; border: 1px solid #e5e5e5; background-color: #fff; cursor: move; padding: 0; margin-right: 10px; margin-bottom: 10px;">';
             echo '<p style="padding: 3px; margin: 0; display: block;">';
             echo wp_get_attachment_image($photo['ID'], 'apg-thumbnail-75-75');
             echo '</p>';
             echo '<div class="apg-delete-photo" data-apgid="' . esc_attr($photo['ID']) . '" style="cursor: pointer;display:block;position:absolute;top:-5px;margin-left: 67px;width: 16px;height:16px;border-radius:10px;padding:0;padding-top:-4px;border: 2px solid #ccc;font-size: 7px;background-color:#333;color:#fff;text-align:center;">X</div>';
             echo '</li>';
             $photo_hidden[] = $photo['ID'];
         }
         echo '</ul></div><div style="clear: both;"></div>';
         echo '<input type="hidden" name="apg_photo_order" id="apg_photo_order" value="' . implode(',', $photo_hidden) . '" />';
         echo '<p><i>' . __('If you want to upload new photos to this album, please use the "Upload photo(s)" menu item on the left.', 'apg') . '</i></p>';
     } else {
         echo '<p><strong>' . __('No photos where uploaded, yet. Please use the submenu item "Upload photo(s)" in the menu to upload new photos, or use the button below.', 'apg') . '</strong></p>';
     }
     echo '<p>' . __('You can add or upload new photo\'s into this album on the upload page.', 'apg') . ' <a href="' . admin_url('edit.php?post_type=apg_photo_albums&page=apg_upload') . '" class="button">' . __('Add new Photo\'s', 'apg') . '</a></p>';
 }
开发者ID:Code-Brothers,项目名称:Awesome-Photo-Gallery,代码行数:34,代码来源:class-post-metabox.php



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP wp_get_attachment_image_sizes函数代码示例发布时间:2022-05-23
下一篇:
PHP wp_get_attachment_id3_keys函数代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap