Changeset 1049144
- Timestamp:
- 12/19/2014 11:16:54 AM (11 years ago)
- Location:
- category-featured-images/trunk
- Files:
-
- 2 edited
-
category-featured-images.php (modified) (5 diffs)
-
readme.txt (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
category-featured-images/trunk/category-featured-images.php
r1041737 r1049144 4 4 * Plugin URI: https://github.com/blocknotes/wordpress_category_featured_images 5 5 * Description: Allows to set featured images for categories, posts without a featured image will show the category's image (Posts \ Categories \ Edit category) 6 * Version: 1.1. 26 * Version: 1.1.5 7 7 * Author: Mattia Roccoberton 8 8 * Author URI: http://blocknot.es … … 58 58 { 59 59 $images = get_option( 'cfi_featured_images' ); 60 $cat = NULL; 60 61 foreach( $categories as $category ) 61 62 { … … 65 66 if( $attachment !== FALSE ) return $attachment[0]; 66 67 } 68 if( $cat === NULL ) $cat = $category; 69 } 70 if( $cat !== NULL ) 71 { 72 $parent = intval( $cat->parent ); 73 if( $parent > 0 && isset( $images[$parent] ) ) 74 { 75 $attachment = wp_get_attachment_image_src( $images[$parent], $size ); 76 if( $attachment !== FALSE ) return $attachment[0]; 77 } 67 78 } 68 79 } … … 90 101 { 91 102 $images = get_option( 'cfi_featured_images' ); 103 $cat = NULL; 92 104 foreach( $categories as $category ) 93 105 { 94 106 if( isset( $images[$category->term_id] ) ) return '<span class="cfi-featured-image">' . wp_get_attachment_image( $images[$category->term_id], $size ) . '</span>'; 107 if( $cat === NULL ) $cat = $category; 108 } 109 if( $cat !== NULL ) 110 { 111 $parent = intval( $cat->parent ); 112 if( $parent > 0 && isset( $images[$parent] ) ) return '<span class="cfi-featured-image">' . wp_get_attachment_image( $images[$parent], $size ) . '</span>'; 95 113 } 96 114 } … … 176 194 // Look for a category featured image 177 195 $categories = wp_get_post_categories( $object_id ); 178 if( isset( $categories[0] ) ) 179 { 180 $images = get_option( 'cfi_featured_images' ); 181 if( $images !== FALSE && isset( $images[$categories[0]] ) ) return $images[$categories[0]]; 182 } 196 $images = get_option( 'cfi_featured_images' ); 197 $cat = NULL; 198 foreach( $categories as $category ) 199 { 200 if( isset( $images[$category] ) ) return $images[$category]; 201 if( $cat === NULL ) $cat = $category; 202 } 203 if( $cat !== NULL ) 204 { // Look for the parent category image 205 $category = get_category( $cat ); 206 if( !empty( $category ) && isset( $category->parent ) ) 207 { 208 $parent = intval( $category->parent ); 209 if( $parent > 0 && isset( $images[$parent] ) ) return $images[$parent]; 210 } 211 } 212 183 213 return ''; 184 214 } -
category-featured-images/trunk/readme.txt
r1041745 r1049144 4 4 Donate link: http://www.blocknot.es/home/me/ 5 5 Requires at least: 3.5.0 6 Tested up to: 4. 06 Tested up to: 4.1 7 7 Stable tag: trunk 8 8 License: GPL3 … … 41 41 * 'cat_id': get the image URL of a specific category id 42 42 43 Notes: 44 45 * If a post has more than a category with a featured image the first available is loaded 46 * If a category hasn't a featured image but it has a parent category with a featured image the parent one is loaded 47 43 48 == Installation == 44 49 … … 53 58 == Upgrade Notice == 54 59 60 = 1.1.5 = 61 * Loads parent category image if nothing is found before 55 62 = 1.1.2 = 56 63 * Added 'cat_id' param to cfi_featured_image_url … … 63 70 == Changelog == 64 71 72 = 1.1.5 = 73 * Loads parent category image if nothing is found before 65 74 = 1.1.2 = 66 75 * Added 'cat_id' param to cfi_featured_image_url
Note: See TracChangeset
for help on using the changeset viewer.