Skip to content

Instantly share code, notes, and snippets.

@tenman
Last active November 20, 2015 02:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tenman/ce43f66371689ad6f503 to your computer and use it in GitHub Desktop.
Save tenman/ce43f66371689ad6f503 to your computer and use it in GitHub Desktop.
WordPress Raindrops Theme. Featured icon size chenge. on index,archives. paste only between code paste start and code paste end. ver 1.336 after.
<?php
// code paste start
add_image_size( 'archive_featured_icon', 100, 50, true );// 100 is width(px) 50 is height(px)
add_filter('raindrops_post_thumbnail_size_main_query','my_post_thumbnail_size_custom' );
add_filter('raindrops_embed_meta_css', 'my_archive_thumbnail_size_custom_style' );
function my_post_thumbnail_size_custom( $size ) {
return 'archive_featured_icon';
return $size;
}
function my_archive_thumbnail_size_custom_style( $css ) {
$image_size = my_get_image_sizes('archive_featured_icon');
$custom_style = '.tag .h2-thumb, .category .h2-thumb, .rd-featured-no-front .h2-thumb, .rd-featured-no-left .h2-thumb,.rd-featured-no-front .h2-thumb, .rd-featured-no-left .h2-thumb{
width: '.absint( $image_size ['width'] ).'px;
}
.tag .h2-thumb .wp-post-image,.category .h2-thumb .wp-post-image, .rd-featured-no-front .h2-thumb .wp-post-image, .rd-featured-no-left .h2-thumb .wp-post-image,.paged .h2-thumb .wp-post-image, .paged .h2-thumb .wp-post-image{
width:'.absint( $image_size ['width'] ).'px;
}';
$custom_style .= '.rsidebar .h2-thumb,.lsidebar .h2-thumb,#ft .h2-thumb,.topsidebar .h2-thumb,
.rsidebar .h2-thumb .wp-post-image,.lsidebar .h2-thumb .wp-post-image,#ft .h2-thumb .wp-post-image,.topsidebar .h2-thumb .wp-post-image{
width:auto;
}';
return $css. $custom_style;
}
function my_get_image_sizes( $size = '' ) {
/* @see https://codex.wordpress.org/Function_Reference/get_intermediate_image_sizes */
global $_wp_additional_image_sizes;
$sizes = array();
$get_intermediate_image_sizes = get_intermediate_image_sizes();
// Create the full array with sizes and crop info
foreach( $get_intermediate_image_sizes as $_size ) {
if ( in_array( $_size, array( 'thumbnail', 'medium', 'large' ) ) ) {
$sizes[ $_size ]['width'] = get_option( $_size . '_size_w' );
$sizes[ $_size ]['height'] = get_option( $_size . '_size_h' );
$sizes[ $_size ]['crop'] = (bool) get_option( $_size . '_crop' );
} elseif ( isset( $_wp_additional_image_sizes[ $_size ] ) ) {
$sizes[ $_size ] = array(
'width' => $_wp_additional_image_sizes[ $_size ]['width'],
'height' => $_wp_additional_image_sizes[ $_size ]['height'],
'crop' => $_wp_additional_image_sizes[ $_size ]['crop']
);
}
}
if ( $size ) {
if( isset( $sizes[ $size ] ) ) {
return $sizes[ $size ];
} else {
return false;
}
}
return $sizes;
}
// code paste end
/**
*
*
* @package Raindrops
* @since Raindrops 0.1
*/
if ( !defined( 'ABSPATH' ) ) {
exit;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment