Exemplo n.º 1
0
/**
 * Retrieves an image based on the attachments for a particular post.
 *
 * @param string $size
 * @param array $original
 * @param bool $get_original
 * @param bool $attachment_id
 * @param array $options
 * @return array|bool|mixed|string|void
 */
function suffusion_get_image_from_attachment($size = 'thumbnail', &$original = array(), $get_original = false, $attachment_id = false, $options = array())
{
    global $post;
    $img = "";
    if (!$attachment_id) {
        $attachments = get_children(array('post_parent' => $post->ID, 'post_status' => 'inherit', 'post_type' => 'attachment', 'post_mime_type' => 'image', 'order' => 'ASC', 'orderby' => 'menu_order'));
        if (is_array($attachments)) {
            foreach ($attachments as $id => $attachment) {
                $img = wp_get_attachment_image_src($id, $size);
                if ($img && $get_original) {
                    $original = wp_get_attachment_image_src($id, 'full');
                }
                break;
            }
        }
    } else {
        $img = wp_get_attachment_image_src($attachment_id, $size);
    }
    // Try YAPB
    if (($img == "" || is_array($img) && count($img) == 0) && function_exists('yapb_is_photoblog_post') && yapb_is_photoblog_post()) {
        $standard_sizes = array('thumbnail', 'medium', 'large');
        if (!isset($width) || !isset($height)) {
            // Retrieve the physical sizes from the named size.
            global $_wp_additional_image_sizes;
            if (isset($_wp_additional_image_sizes[$size])) {
                $size_array = $_wp_additional_image_sizes[$size];
                $width = $size_array['width'];
                $height = $size_array['height'];
            } else {
                if (in_array($size, $standard_sizes)) {
                    $width = get_option($size . '_size_w');
                    $height = get_option($size . '_size_h');
                } else {
                    $width = get_option('full_size_w');
                    $height = get_option('full_size_h');
                }
            }
            if (isset($options["featured"]) || isset($options['featured-widget'])) {
                $img_class = "featured-excerpt-" . $options["excerpt_position"];
            } else {
                if (isset($options['mag-headline']) || isset($options['mag-excerpt']) || isset($options['tile-thumb'])) {
                    $img_class = '';
                } else {
                    if (isset($options['mosaic-thumb'])) {
                        $img_class = 'suf-mosaic-img';
                    } else {
                        if (isset($options['widget-thumb'])) {
                            $img_class = 'suf-widget-thumb';
                        } else {
                            global $suf_excerpt_thumbnail_alignment;
                            $img_class = $suf_excerpt_thumbnail_alignment . '-thumbnail';
                        }
                    }
                }
            }
            $img = yapb_get_thumbnail('', array('alt' => esc_attr($post->post_title)), '', array("w={$width}", "h={$height}", "q=100"), $img_class);
            $original['yapb'] = true;
        }
    }
    return $img;
}
Exemplo n.º 2
0
                } else {
                    if (is_page()) {
                        query_posts($perpage);
                    } else {
                        query_posts('category_name=' . get_page_uri($post->ID) . $perpage);
                    }
                }
            }
        }
    }
}
the_post();
?>
 
							<?php 
if (yapb_is_photoblog_post()) {
    ?>
								<?php 
    $title = the_title('', '', false);
    echo yapb_get_thumbnail('<p class="thumbnail"><a rel=\'bookmark\' title=\'' . $title . '\' href=\'' . get_permalink() . '\'>', array('alt' => $title, 'title' => $title), '</a></p>', array('w=90', 'q=90'));
    ?>
							<?php 
}
?>
							<?php 
wp_reset_query();
?>
						</div>
					</div>
					<ul id="globalNav" class="nav global">
						<li <?php 
Exemplo n.º 3
0
 /**
  * Generates an excerpt with additional parameters
  *
  * @param bool $show_image 			Shows a thumbnail if set to true
  * @param bool $echo 				Echoes the output
  * @param bool $filter_length		Whether a filter should be applied to restrict the length of the excerpt
  * @param string $length_callback	Function to call for controlling the excerpt length. Default is <code>suffusion_excerpt_length</code>
  * @return mixed|string|void
  */
 function suffusion_excerpt($show_image = false, $echo = true, $filter_length = true, $length_callback = 'suffusion_excerpt_length')
 {
     $ret = "";
     if ($show_image) {
         $ret = suffusion_get_image(array());
     }
     if ($filter_length) {
         if (function_exists($length_callback)) {
             add_filter('excerpt_length', $length_callback);
         } else {
             add_filter('excerpt_length', 'suffusion_excerpt_length');
         }
     }
     // If this is a YAPB post, disable this filter, otherwise the YAPB thumbnail is shown in excerpts...
     if (function_exists('yapb_is_photoblog_post') && yapb_is_photoblog_post()) {
         global $yapb;
         remove_filter('the_content', array(&$yapb, '_filter_the_content'));
     }
     $excerpt = get_the_excerpt();
     $excerpt = apply_filters('the_excerpt', $excerpt);
     $ret .= $excerpt;
     if ($echo) {
         echo $ret;
     }
     // If this is a YAPB post, re-add this filter for full content posts
     if (function_exists('yapb_is_photoblog_post') && yapb_is_photoblog_post()) {
         global $yapb;
         add_filter('the_content', array(&$yapb, '_filter_the_content'));
     }
     return $ret;
 }