Exemplo n.º 1
0
function getImageByPost($post)
{
    $cate = get_the_category();
    //echo $cate[0]->cat_ID;
    //$post->post_parent->term_id
    if (has_post_thumbnail($post->ID)) {
        $image = wp_get_attachment_image_src(get_post_thumbnail_id($post->ID), 'medium');
        $image = $image[0];
        return $image;
    } elseif (strlen($catImageUrl = getCategoryImage($cate[0]->cat_ID)) > 0) {
        return $catImageUrl;
    } elseif (strlen(getFirstImage($post->ID)) > 0) {
        $image = getFirstImage($post->ID);
        return $image;
    } else {
        $theme = get_option('themes');
        if ($theme == '10') {
            return get_stylesheet_directory_uri() . '/asset/img/themes/post-default10.jpg';
            // TODO 常量化
        } elseif ($theme == 11) {
            return get_stylesheet_directory_uri() . '/asset/img/themes/post-default11.jpg';
        } elseif ($theme == 12) {
            return get_stylesheet_directory_uri() . '/asset/img/themes/post-default12.jpg';
        } else {
            return get_stylesheet_directory_uri() . '/asset/img/themes/post-default10.jpg';
            // TODO
        }
    }
}
Exemplo n.º 2
0
function showFeaturedChildPage($pageTitle = "Issues", $daysUntilExpires = 14)
{
    // Get the page as an Object
    $issues = get_page_by_title($pageTitle);
    $issuesID = $issues->ID;
    $args = array('post_parent' => $issuesID, 'post_type' => 'page', 'numberposts' => 1, 'post_status' => 'publish');
    $issues = get_children($args);
    //print_r($issues);
    $issueContent = "";
    foreach ($issues as $issue) {
        $issueTimestamp = strtotime($issue->post_date);
        $todayTimestamp = strtotime("today");
        if ($todayTimestamp > $issueTimestamp + $daysUntilExpires * 24 * 60 * 60) {
            return;
        }
        $issueLink = get_permalink($issue->ID);
        $issueContent .= "<div class='showFeaturedChildPage'>";
        $issueContent .= '<h3 class="entry-title"><a href="' . $issueLink . '">' . $issue->post_title . '</a></h3>';
        $issueContent .= "<div class='text'>";
        $text = $issue->post_content;
        //$text = wpautop( $issue->post_content );
        /*
        $text = strip_shortcodes( $text );
        // Strip JW Player shortcode too
        $text = preg_replace( '/(.?)\[(flv)\b(.*?)(?:(\/))?\](?:(.+?)\[\/\2\])?(.?)/s', '$1$6', $text );
        //$text = strip_tags($text, '<a>, <span>, <p>, <strong>, <em>, <b>');
        $text = apply_filters('the_content', $text);
        //$text = neatTrim($text, $maxLength,'More');
        
        //Get first paragraph
        $text = substr( $text, 0, strpos( $text, '</p>' ) + 4 );
        $text = strip_tags($text, '<a><strong><em>');
        $text =  '<p>' . $text . ' <a href="'. get_permalink($issue->ID) .'">More</a></p>';
        	
        $issueContent .= $text;	
        */
        $firstImg = getFirstImage($issue->ID, 'full');
        $issueContent .= "<a href='{$issueLink}'><img src='{$firstImg['0']}' class='page-feat' /></a>";
        $issueContent .= "</div>";
        $issueContent .= "</div>";
    }
    echo $issueContent;
}
Exemplo n.º 3
0
                            <img class="product-image" src="<?php 
            echo $image;
            ?>
" alt="<?php 
            the_title();
            ?>
" title="<?php 
            the_title();
            ?>
"/>
                        <?php 
        } elseif (strlen(getFirstImage($post->ID)) > 0) {
            ?>
 
                        	<?php 
            $image = getFirstImage($post->ID);
            ?>
  
                            <img class="product-image" src="<?php 
            echo $image;
            ?>
" alt="<?php 
            the_title();
            ?>
" title="<?php 
            the_title();
            ?>
"/>
						<?php 
        } else {
            ?>
				<a href="<?php 
        the_permalink();
        ?>
" rel="bookmark" title="<?php 
        the_title_attribute();
        ?>
"  onClick="_gaq.push(['_trackEvent', 'Blog-RelatedPost', 'Clicked', '<?php 
        the_title();
        ?>
']);" class='yarpp-thumbnail'>
									
					<?php 
        if (get_the_post_thumbnail() != '') {
            the_post_thumbnail('thumbnail');
        } elseif (function_exists('getFirstImage') && getFirstImage(get_the_ID(), 'thumbnail')) {
            $iStuff = getFirstImage(get_the_ID(), 'thumbnail');
            $iSrc = $iStuff[0];
            ?>
							
						<img src="<?php 
            echo $iSrc;
            ?>
" width="130" height="130" />
						
					<?php 
        } else {
            ?>
						
							<img src="http://openspace.sfmoma.org/img/common/letter-o-video_130x130.png" />
					
					<?php 
Exemplo n.º 5
0
        }
        ?>
						<?php 
        // wp_link_pages(array('before' => '<p><strong>Pages:</strong> ', 'after' => '</p>', 'next_or_number' => 'number'));
        ?>
					</div>
				</div>
					<?php 
        if (isset($youtube) && $ytcheck == 'on') {
            //we have a youtube vid for the homepage
            echo $ytembed;
        } elseif (isset($flv) && $flvcheck == 'on') {
            //we have an FLV for the homepage
            echo $flvembed;
        } elseif ($fwcheck == 'off' || !isset($fwcheck)) {
            if (function_exists('getFirstImage') && getFirstImage($post->ID)) {
                ?>
					<div class='right' <?php 
                echo 'style="width:' . $iWidth . 'px"';
                ?>
 >
						<a href="<?php 
                the_permalink();
                ?>
" rel="bookmark" title="<?php 
                echo strip_tags($iCap);
                ?>
">	
							<img <?php 
                echo 'style="width:' . $iWidth . 'px"';
                ?>
Exemplo n.º 6
0
$query = '
						SELECT galleries.*, 
						(
							SELECT COUNT(*) FROM images 
							WHERE images.images_gallery_id = galleries.galleries_id 
							AND images.images_active = "1" 
							AND images.images_deleted = "0" 
						) AS "images" 
						FROM galleries 
						WHERE galleries_active = "1" 
						AND galleries_deleted = "0" 
						' . $order_by . ' ';
$result = mysqli_query($db, $query);
$gallery_count = 1;
while ($gallery = mysqli_fetch_array($result)) {
    $first_image = getFirstImage($gallery['galleries_id']);
    echo '
								<div class="panel panel-default">
									<div class="panel-heading"><span style="font-weight: bold;">Gallery #' . $gallery_count . ':</span> ' . $gallery['galleries_title'] . '</div>
									<div class="panel-body">
									<img src="' . $first_image['images_prefix'] . '/' . $first_image['images_filename'] . '" style="width: 80px; float: left; margin-right: 15px;"/>
									Gallery imported at ' . $gallery['galleries_created'] . ', contains ' . countImagesInGallery($gallery['galleries_id']) . ' pictures.<br/>
										<a href="index.php?show=gallery&id=' . $gallery['galleries_id'] . '" class="btn btn-sm btn-default">Show Gallery</a>
										<a href="' . $gallery['galleries_link'] . '" target="_blank" class="btn btn-sm btn-default">Open Source Page</a>
									</div>
								</div>
							';
    $gallery_count++;
}
?>
  				</div>
Exemplo n.º 7
0
 results for <span class="searchwords">&ldquo;<?php 
    echo get_search_query();
    ?>
&rdquo;</span></h1>

		<?php 
    while (have_posts()) {
        the_post();
        if (has_post_thumbnail()) {
            //we have a featured image
            $thumbId = get_post_thumbnail_id($post->ID);
            $iStuff = wp_get_attachment_image_src($thumbId, 'search-thumb');
            $iSrc = $iStuff[0];
        } elseif (function_exists('getFirstImage') && getFirstImage($post->ID)) {
            //no featured or youtube, any other attachments?
            $iStuff = getFirstImage($post->ID, 'search-thumb');
            $iSrc = $iStuff[0];
        }
        ?>
		
		
			<div class="post clearfix">
				<div class="right searchitem">
					<h3 id="post-<?php 
        the_ID();
        ?>
"><a href="<?php 
        the_permalink();
        ?>
" rel="bookmark" title="Permanent Link to <?php 
        the_title_attribute();