Example #1
6
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();
}
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;
    }
}
Example #3
0
/**
 * 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;
}
Example #4
0
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
}
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 . '" />';
            }
        }
    }
}
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;
}
Example #7
0
 /**
  * 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);
 }
 /**
  * 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;
 }
Example #9
0
/**
 * 
 * @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]);
        }
    }
}
Example #10
0
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;
}
Example #11
0
    /**
     * 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 
        }
    }
Example #12
0
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;
}
Example #13
0
/**
 * 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();
}
/**
 * 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;
}
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;
}
Example #16
0
function get_image_url()
{
    $image_id = get_post_thumbnail_id();
    $image_url = wp_get_attachment_image_src($image_id, 'large');
    $image_url = $image_url[0];
    echo $image_url;
}
    /**
     * Social Media Share Shortcode
     * 
     * @global class $post 
     * 
     * @param  array $atts
     * @param  string $content
     * @return string $output
     */
    function rt_social_media_share($atts = array(), $content = null)
    {
        global $post;
        //Available Social Media Icons
        $rt_social_share_list = apply_filters("rt_social_media_list", array("Email" => array("icon_name" => "mail", "url" => "mailto:?body=[URL]", "popup" => false), "Twitter" => array("icon_name" => "twitter", "url" => "http://twitter.com/home?status=[TITLE]+[URL]", "popup" => true), "Facebook" => array("icon_name" => "facebook", "url" => "http://www.facebook.com/sharer/sharer.php?u=[URL]&amp;title=[TITLE]", "popup" => true), "Google +" => array("icon_name" => "gplus", "url" => "https://plus.google.com/share?url=[URL]", "popup" => true), "Pinterest" => array("icon_name" => "pinterest", "url" => "http://pinterest.com/pin/create/bookmarklet/?media=[MEDIA]&amp;url=[URL]&amp;is_video=false&amp;description=[TITLE]", "popup" => true), "Tumblr" => array("icon_name" => "tumblr", "url" => "http://tumblr.com/share?url=[URL]&amp;title=[TITLE]", "popup" => true), "Linkedin" => array("icon_name" => "linkedin", "url" => "http://www.linkedin.com/shareArticle?mini=true&amp;url=[URL]&amp;title=[TITLE]&amp;source=", "popup" => true), "Vkontakte" => array("icon_name" => "vkontakte", "url" => "http://vkontakte.ru/share.php?url=[URL]", "popup" => true)));
        $title = urlencode(get_the_title($post->ID));
        $permalink = urlencode(get_the_permalink($post->ID));
        $image = urlencode(rt_get_attachment_image_src(get_post_thumbnail_id($post->ID)));
        $output = "";
        foreach ($rt_social_share_list as $key => $value) {
            $value["url"] = str_replace("[URL]", $permalink, $value["url"]);
            $value["url"] = str_replace("[TITLE]", $title, $value["url"]);
            $value["url"] = str_replace("[MEDIA]", $image, $value["url"]);
            $output .= '<li class="' . $value["icon_name"] . '">';
            $output .= $value["popup"] ? '<a class="icon-' . $value["icon_name"] . ' " href="#" data-url="' . $value["url"] . '" title="' . $key . '">' : '<a class="icon-' . $value["icon_name"] . ' " href="' . $value["url"] . '" title="' . $key . '">';
            $output .= '<span>' . $key . '</span>';
            $output .= '</a>';
            $output .= '</li>';
        }
        return '
		<div class="social_share_holder">
		<div class="share_text"><span class="icon-share">' . __("Share", "rt_theme") . '</span></div>
		<ul class="social_media">' . $output . '</ul>
		</div>';
    }
function post_grid_get_media($media_source, $featured_img_size)
{
    $html_thumb = '';
    if ($media_source == 'featured_image') {
        $thumb = wp_get_attachment_image_src(get_post_thumbnail_id(get_the_ID()), $featured_img_size);
        $thumb_url = $thumb['0'];
        if (!empty($thumb_url)) {
            $html_thumb .= '<img src="' . $thumb_url . '" />';
        } else {
            $html_thumb .= '';
        }
    } elseif ($media_source == 'empty_thumb') {
        $html_thumb .= '<img src="' . post_grid_plugin_url . 'assets/frontend/css/images/placeholder.png" />';
    } elseif ($media_source == 'first_image') {
        global $post, $posts;
        $first_img = '';
        ob_start();
        ob_end_clean();
        $output = preg_match_all('/<img.+src=[\'"]([^\'"]+)[\'"].*>/i', $post->post_content, $matches);
        if (!empty($matches[1][0])) {
            $first_img = $matches[1][0];
        }
        if (empty($first_img)) {
            $html_thumb .= '';
        } else {
            $html_thumb .= '<img src="' . $first_img . '" />';
        }
    }
    return $html_thumb;
}
Example #19
0
function sys_recent_posts($atts, $content = null)
{
    extract(shortcode_atts(array('limit' => '2', 'description' => '40', 'cat_id' => '23', 'thumb' => 'true', 'postdate' => ''), $atts));
    $out = '<div class="widget_postslist sc">';
    $out .= '<ul>';
    global $wpdb;
    $myposts = get_posts("numberposts={$limit}&offset=0&cat={$cat_id}");
    foreach ($myposts as $post) {
        $post_date = $post->post_date;
        $post_date = mysql2date('F j, Y', $post_date, false);
        $out .= "<li>";
        if ($thumb == "true") {
            $thumbid = get_post_thumbnail_id($post->ID);
            $imgsrc = wp_get_attachment_image_src($thumbid, array(9999, 9999));
            $out .= '<div class="thumb"><a href="' . get_permalink($post->ID) . '" title="' . $post->post_title . '">';
            if ($thumbid) {
                $out .= atp_resize('', $imgsrc['0'], '50', '50', 'imgborder', '');
            } else {
                //$out .= '<img class="imgborder" src="'.THEME_URI.'/images/no-image.jpg'.'"  alt="' .$post->post_title. '" />';
            }
            $out .= '</a></div>';
        }
        $out .= '<div class="pdesc"><a href="' . get_permalink($post->ID) . '" rel="bookmark">' . $post->post_title . '</a>';
        if ($postdate == "true") {
            $out .= '<div class="w-postmeta"><span>' . $post_date . '</span></div>';
        } else {
            $out .= '<p>' . wp_html_excerpt($post->post_content, $description, '...') . '</p>';
        }
        $out .= '</div></li>';
    }
    $out .= '</ul></div>';
    return $out;
    wp_reset_query();
}
Example #20
0
function post_thumbnail_url()
{
    $thumb_id = get_post_thumbnail_id();
    $thumb_url_array = wp_get_attachment_image_src($thumb_id, 'full');
    $thumb_url = $thumb_url_array[0];
    echo $thumb_url;
}
Example #21
0
function get_thumb_urlfull($postID)
{
    $image_id = get_post_thumbnail_id($post);
    $image_url = wp_get_attachment_image_src($image_id, 'large');
    $image_url = $image_url[0];
    return $image_url;
}
Example #22
0
function add_uw_feed_enclosure_image()
{
    global $post;
    $thumbnailID = get_post_thumbnail_id($post->ID);
    if (!empty($thumbnailID)) {
        $url = wp_get_attachment_image_src($thumbnailID, 'rss');
        $url = $url[0];
        //$mime = get_post_mime_type($thumbnailID);  unneeded DB call to get mime type
        $img_headers = get_headers($url);
        foreach ($img_headers as $img_header) {
            $info = explode(" ", $img_header);
            if ($info[0] == 'Content-Length:') {
                $size = $info[1];
            } else {
                if ($info[0] == 'Content-Type:') {
                    $mime = $info[1];
                }
            }
        }
        ?>
        <enclosure url="<?php 
        echo $url;
        ?>
" type="<?php 
        echo $mime;
        ?>
" size="<?php 
        echo $size;
        ?>
" />
        <?php 
    }
}
Example #23
0
 /**
  * Adds columns in the admin view for thumbnail and taxonomies
  *
  * @since   2.0.0
  * @access  public
  */
 public function cols_display($staff_columns, $post_id)
 {
     switch ($staff_columns) {
         // Display the thumbnail in the column view
         case "staff_thumbnail":
             // Get post thumbnail ID
             $thumbnail_id = get_post_thumbnail_id();
             // Display the featured image in the column view if possible
             if ($thumbnail_id) {
                 $thumb = wp_get_attachment_image($thumbnail_id, array('80', '80'), true);
             }
             if (isset($thumb)) {
                 echo $thumb;
             } else {
                 echo '&mdash;';
             }
             break;
             // Display the staff tags in the column view
         // Display the staff tags in the column view
         case "staff_category":
             if ($category_list = get_the_term_list($post_id, 'staff_category', '', ', ', '')) {
                 echo $category_list;
             } else {
                 echo __('None', 'wpex');
             }
             break;
     }
 }
Example #24
0
function mostrarRevistas()
{
    // WP_Query arguments
    $args = array('post_type' => array('revistas'), 'order' => 'DESC');
    // The Query
    $revistas = new WP_Query($args);
    if ($revistas->have_posts()) {
        $outputs = '<div class="grids entries revistas">';
        while ($revistas->have_posts()) {
            $revistas->the_post();
            $thumb_id = get_post_thumbnail_id();
            $thumb_url = wp_get_attachment_image_src($thumb_id, 'big', true);
            $url = $thumb_url[0];
            $outputs .= '<article class="grid-3 post type-post format-standard has-post-thumbnail hentry">';
            $outputs .= '<figure class="entry-image inview">';
            $outputs .= '<a href="' . get_the_permalink() . '">';
            $outputs .= '<img src="' . $url . '" class="attachment-rectangle-size wp-post-image" alt="' . get_the_title() . '">';
            $outputs .= '</a>';
            $outputs .= '</figure>';
            $outputs .= '<header class="entry-header">';
            $outputs .= '<h2 class="entry-title"><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h2>';
            $outputs .= '</header>';
            $outputs .= '</article>';
        }
        $outputs .= '</div>';
    }
    wp_reset_query();
    // Restore global post data stomped by the_post().
    return $outputs;
}
function image_cpt_shortcode($attr)
{
    if ($attr['page'] <= 10) {
        $per_page['page'] = $attr['page'];
    } else {
        $per_page['page'] = 10;
    }
    $output = '<h2 class="winner-title">Hall of Winners</h2><h3 class="winner-subtitle">Congratulations to all of our winners</h3>';
    $args = array('post_type' => 'image_post_type', 'posts_per_page' => $per_page['page']);
    $loop = new WP_query($args);
    if ($loop->have_posts()) {
        while ($loop->have_posts()) {
            $loop->the_post();
            $output .= '<div class="winner-div"><h3>';
            $output .= get_the_title();
            $output .= '</h3>';
            if (has_post_thumbnail()) {
                // check if the post has a post thumbnail assigned to it.
                $thumb = wp_get_attachment_image_src(get_post_thumbnail_id($loop->ID), 'full');
                $url = $thumb['0'];
                $output .= '<img src="' . $url . '"/>';
            }
            $output .= '</div>';
        }
    } else {
        // if no content, include the "no posts found" template.
        get_template_part('content', 'none');
    }
    return $output;
}
Example #26
0
 public function get($type = "", $id = "", $size = "", $attr = array())
 {
     if (is_array($id) && $id["id"]) {
         $id = $id["id"];
     }
     if (!$id) {
         $id = get_post_thumbnail_id(get_the_ID());
     }
     if (!$id) {
         $id = get_field('image', get_the_ID());
         $id = $id["id"];
     }
     if (!$id) {
         $id = get_field('placeholder', 'options');
     }
     if (!$id) {
         return;
     }
     if ($type == "html") {
         return wp_get_attachment_image($id, $size);
     } else {
         if ($type == "url") {
             return reset(wp_get_attachment_image_src($id, $size));
         } else {
             if ($type == "") {
                 return wp_get_attachment_metadata($id);
             } else {
                 $res = wp_get_attachment_metadata($id);
                 return $res[$type];
             }
         }
     }
 }
Example #27
0
function vr_set_featured_background()
{
    $image_url = wp_get_attachment_image_src(get_post_thumbnail_id($post->ID), full, false);
    if ($image_url[0]) {
        ?>
     <style>
     
       html,body {
       height:100%;
       margin:0!important;
       }
       body {
       background: url(<?php 
        echo $image_url[0];
        ?>
) #000 center top;
       background-size: contain;
       height: 100vh;
       }
       @media all and (max-width: 940px) {
        body {
          height: auto;
          background-size: cover;
          background-position: center top;
        }
      }
     </style>
   <?php 
    }
    //end if statement
}
Example #28
0
function rs_option_page_new()
{
    $slider = new WP_Query(array('post_type' => 'slideshow', 'order' => 'ASC'));
    if ($slider->have_posts()) {
        ?>

		<ul class="bxslider">
			<?php 
        while ($slider->have_posts()) {
            $slider->the_post();
            ?>
				<li>
					<?php 
            $thumb = wp_get_attachment_image_src(get_post_thumbnail_id($post->ID), 'full');
            $url = $thumb['0'];
            ?>
					<img src="<?php 
            echo $url;
            ?>
" title="<?php 
            the_content();
            ?>
">
				</li>
			<?php 
        }
        ?>
		</ul>
	<?php 
    } else {
        ?>
		<div><h2>This plase slider</h2></div>
	<?php 
    }
}
Example #29
0
function print_blog_thumbnail($post_id, $item_size)
{
    $thumbnail_types = get_post_meta($post_id, 'post-option-thumbnail-types', true);
    if ($thumbnail_types == "Image" || empty($thumbnail_types)) {
        $thumbnail_id = get_post_thumbnail_id($post_id);
        $thumbnail = wp_get_attachment_image_src($thumbnail_id, $item_size);
        $alt_text = get_post_meta($thumbnail_id, '_wp_attachment_image_alt', true);
        if (!empty($thumbnail)) {
            echo '<div class="blog-thumbnail-image">';
            echo '<a href="' . get_permalink() . '"><img src="' . $thumbnail[0] . '" alt="' . $alt_text . '"/></a></div>';
        }
    } else {
        if ($thumbnail_types == "Video") {
            $video_link = get_post_meta($post_id, 'post-option-thumbnail-video', true);
            echo '<div class="blog-thumbnail-video">';
            echo get_video($video_link, gdl_get_width($item_size), gdl_get_height($item_size));
            echo '</div>';
        } else {
            if ($thumbnail_types == "Slider") {
                $slider_xml = get_post_meta($post_id, 'post-option-thumbnail-xml', true);
                $slider_xml_dom = new DOMDocument();
                $slider_xml_dom->loadXML($slider_xml);
                echo '<div class="blog-thumbnail-slider">';
                echo print_flex_slider($slider_xml_dom->documentElement, $item_size);
                echo '</div>';
            }
        }
    }
}
Example #30
0
 /**
  * Determine the correct image to use for the post
  */
 function get_image()
 {
     // Get the arguments
     $args = $this->args;
     $image = array();
     extract($args);
     // First use the "Featured Image" thumbnail if set
     $thumb_id = get_post_thumbnail_id($post_id);
     if (!empty($thumb_id)) {
         $thumb_id = get_post_thumbnail_id($post_id);
         $src = wp_get_attachment_image_src($thumb_id, $size);
         $img = $src[0];
         // Next try scanning the post for attachments
     } else {
         $att_args = array('numberposts' => 1, 'post_type' => 'attachment', 'post_parent' => $post_id, 'post_mime_type' => 'image', 'post_status' => null);
         $attachments = get_children($att_args);
         // If attachments were found, grab the first one which is a valid image
         if ($attachments) {
             foreach ($attachments as $att) {
                 $src = wp_get_attachment_image_src($att->ID, $size);
                 $img = $src[0];
                 if (!empty($img)) {
                     break;
                 }
             }
         }
         // If we still have nothing, grab a default
         if (empty($img)) {
             $img = THEME_URI . '/images/avatars/foundry-thumb.jpg';
         }
     }
     // Return the image
     return $img;
 }