コード例 #1
-1
ファイル: qode.functions.php プロジェクト: surreal8/wptheme
function qodef_get_attachment_thumb_url($attachment_url)
{
    $attachment_id = qode_get_attachment_id_from_url($attachment_url);
    if (!empty($attachment_id)) {
        return wp_get_attachment_thumb_url($attachment_id);
    } else {
        return $attachment_url;
    }
}
コード例 #2
-1
ファイル: functions.php プロジェクト: BaristaCom/wp-base
 /**
  * Function that returns meta array for give attachment url
  * @param $attachment_url
  * @param array $keys sub array of attachment meta
  * @return array|mixed
  *
  * @see qode_get_attachment_id_from_url()
  * @see qode_get_attachment_meta()
  *
  * @version 0.1
  */
 function qode_get_attachment_meta_from_url($attachment_url, $keys = array())
 {
     $attachment_meta = array();
     //get attachment id for attachment url
     $attachment_id = qode_get_attachment_id_from_url($attachment_url);
     //is attachment id set?
     if (!empty($attachment_id)) {
         //get post meta
         $attachment_meta = qode_get_attachment_meta($attachment_id, $keys);
     }
     //return post meta
     return $attachment_meta;
 }
コード例 #3
-1
ファイル: shortcodes.php プロジェクト: BaristaCom/wp-base
 function qode_carousel($atts, $content = null)
 {
     $args = array("carousel" => "", "orderby" => "date", "order" => "ASC", "show_in_two_rows" => "");
     extract(shortcode_atts($args, $atts));
     $html = "";
     $carousel_holder_classes = "";
     if ($carousel != "") {
         if ($show_in_two_rows == 'yes') {
             $carousel_holder_classes = ' two_rows';
         }
         $html .= "<div class='qode_carousels_holder clearfix" . $carousel_holder_classes . "'><div class='qode_carousels'><ul class='slides'>";
         $q = array('post_type' => 'carousels', 'carousels_category' => $carousel, 'orderby' => $orderby, 'order' => $order, 'posts_per_page' => '-1');
         query_posts($q);
         if (have_posts()) {
             $postCount = 1;
             while (have_posts()) {
                 the_post();
                 if (get_post_meta(get_the_ID(), "qode_carousel-image", true) != "") {
                     $image = get_post_meta(get_the_ID(), "qode_carousel-image", true);
                 } else {
                     $image = "";
                 }
                 if (get_post_meta(get_the_ID(), "qode_carousel-hover-image", true) != "") {
                     $hover_image = get_post_meta(get_the_ID(), "qode_carousel-hover-image", true);
                     $has_hover_image = "has_hover_image";
                 } else {
                     $hover_image = "";
                     $has_hover_image = "";
                 }
                 if (get_post_meta(get_the_ID(), "qode_carousel-item-link", true) != "") {
                     $link = get_post_meta(get_the_ID(), "qode_carousel-item-link", true);
                 } else {
                     $link = "";
                 }
                 if (get_post_meta(get_the_ID(), "qode_carousel-item-target", true) != "") {
                     $target = get_post_meta(get_the_ID(), "qode_carousel-item-target", true);
                 } else {
                     $target = "_self";
                 }
                 $title = get_the_title();
                 //is current item not on even position in array and two rows option is chosen?
                 if ($postCount % 2 !== 0 && $show_in_two_rows == 'yes') {
                     $html .= "<li class='item'>";
                 } elseif ($show_in_two_rows == '') {
                     $html .= "<li class='item'>";
                 }
                 $html .= '<div class="carousel_item_holder">';
                 if ($link != "") {
                     $html .= "<a href='" . $link . "' target='" . $target . "'>";
                 }
                 $first_image = qode_get_attachment_id_from_url($image);
                 if ($image != "") {
                     $html .= "<span class='first_image_holder " . $has_hover_image . "'>";
                     if (is_int($first_image)) {
                         $html .= wp_get_attachment_image($first_image, 'full');
                     } else {
                         $html .= '<img src="' . $image . '" alt="carousel image" />';
                     }
                     $html .= "</span>";
                 }
                 $second_image = qode_get_attachment_id_from_url($hover_image);
                 if ($hover_image != "") {
                     $html .= "<span class='second_image_holder " . $has_hover_image . "'>";
                     if (is_int($second_image)) {
                         $html .= wp_get_attachment_image($second_image, 'full');
                     } else {
                         $html .= '<img src="' . $hover_image . '" alt="carousel image" />';
                     }
                     $html .= "</span>";
                 }
                 if ($link != "") {
                     $html .= "</a>";
                 }
                 $html .= '</div>';
                 //is current item on even position in array and two rows option is chosen?
                 if ($postCount % 2 == 0 && $show_in_two_rows == 'yes') {
                     $html .= "</li>";
                 } elseif ($show_in_two_rows == '') {
                     $html .= "</li>";
                 }
                 $postCount++;
             }
         } else {
             $html .= __('Sorry, no posts matched your criteria.', 'qode');
         }
         wp_reset_query();
         $html .= "</ul>";
         $html .= "</div></div>";
     }
     return $html;
 }
コード例 #4
-1
 /**
  * Generates thumbnail img tag. It calls qode_resize_image function which resizes img on the fly
  * @param null $attach_id attachment id
  * @param null $attach_url attachment URL
  * @param  int$width width of thumbnail
  * @param int $height height of thumbnail
  * @param bool $crop whether to crop thumbnail or not
  * @return string generated img tag
  *
  * @see qode_resize_image()
  * @see qode_get_attachment_id_from_url()
  */
 function qode_generate_thumbnail($attach_id = null, $attach_url = null, $width = null, $height = null, $crop = true)
 {
     //is attachment id empty?
     if (empty($attach_id)) {
         //get attachment id from attachment url
         $attach_id = qode_get_attachment_id_from_url($attach_url);
     }
     if (!empty($attach_id) || !empty($attach_url)) {
         $img_info = qode_resize_image($attach_id, $attach_url, $width, $height, $crop);
         $img_alt = !empty($attach_id) ? get_post_meta($attach_id, '_wp_attachment_image_alt', true) : '';
         if (is_array($img_info) && count($img_info)) {
             return '<img src="' . $img_info['img_url'] . '" alt="' . $img_alt . '" width="' . $img_info['img_width'] . '" height="' . $img_info['img_height'] . '" />';
         }
     }
     return '';
 }
コード例 #5
-1
" />
                </a>
            <?php 
        }
    }
}
if (is_array($portfolio_images) && count($portfolio_images)) {
    foreach ($portfolio_images as $portfolio_image) {
        ?>

			<?php 
        if ($portfolio_image['portfolioimg'] != "") {
            ?>
				<?php 
            list($id, $title, $alt) = qode_get_portfolio_image_meta($portfolio_image['portfolioimg']);
            $single_image_id = qode_get_attachment_id_from_url($portfolio_image['portfolioimg']);
            if (!empty($single_image_id)) {
                $single_image_gallery_thumb_size = get_post_meta(get_the_ID(), 'qode_choose-portfolio-image-size', true);
                $single_image_size = !empty($single_image_gallery_thumb_size) ? get_post_meta(get_the_ID(), 'qode_choose-portfolio-image-size', true) : 'full';
                $single_image_src = wp_get_attachment_image_src($single_image_id, $single_image_size);
                if (is_array($single_image_src)) {
                    $single_image_src = $single_image_src[0];
                }
            } else {
                $single_image_src = stripslashes($portfolio_image['portfolioimg']);
            }
            ?>
				<?php 
            if ($lightbox_single_project == "yes") {
                ?>
					<a class="lightbox_single_portfolio <?php