• Resolved bogdandimitrov

    (@bogastyle)


    Hi Sir,

    I have some custom image sizes in my theme, like:

    if ( function_exists( 'add_theme_support' ) ) {
    	add_theme_support( 'post-thumbnails' );
    	set_post_thumbnail_size( 220, 160, true ); // Normal post thumbnails
    	add_image_size( 'small-image', 160, 160, true ); // Full size screen
    	add_image_size( 'post-big-image', 618, 400, true ); // Full size screen
    	add_image_size( 'original-image', 720, 540, true ); // Full size screen
    	add_image_size( 'header-image', 940, 300, true ); // Full size screen
    	add_image_size( 'vertical', 680, 907, false ); // Full size screen
    }

    I have custom post type “slide” for slideshow and there is custom field type image.

    I want to print out in my theme “header-image” size of image.

    My current code is:

    <?php
    					while ($my_query->have_posts()) : $my_query->the_post();
    					$slidetitle = get_the_title();
    					$slidetext = get_the_content();
    					$slideimage = get_custom_field('bod_slide_image:to_image_src', 'header-image');
    					$slidelink = get_post_meta($post->ID, bod_slide_link, true);
    					?>
                        <li>
                        	<figure>
    							<?php if( $slidelink ) : ?>
                                <a href="<?php echo $slidelink; ?>" title="<?php echo $slidetitle; ?>"><img src="<?php echo $slideimage; ?>" alt="<?php echo $slidetext; ?>" /></a>
                                <?php else : ?>
                                <img src="<?php echo $slideimage; ?>" alt="<?php echo $slidetext; ?>" />
                                <?php endif; ?>
                            </figure>
                        </li>
    					<?php endwhile; ?>

    This work if I crop image before upload.
    It is possible, some how, to upload full image and then take specific size in theme.

    http://wordpress.org/extend/plugins/custom-content-type-manager/

Viewing 1 replies (of 1 total)
  • Thread Starter bogdandimitrov

    (@bogastyle)

    OK. I found decision.

    <?php
    		$slideimage_id = get_custom_field('bod_slide_image:raw'); // <-- get the raw post id
    		$croped_slideimage = CCTM::filter( $slideimage_id, 'to_image_tag', 'header-image'); // <-- get needed custom image size
    
    		echo $croped_slideimage; // <-- echo image tag
    	?>

Viewing 1 replies (of 1 total)
  • The topic ‘How to get specific custom image size in template’ is closed to new replies.