• Resolved burakakin

    (@burakakin)


    Hello,

    I am trying to convert a bootstrap 3 template. I created a custom post type “workshop” and image size 277×185.
    add_image_size('portfolio-item',277,185,true);

    Template uses images as html5. How can I use theme inside template

    <div data-width="240" data-height="161" data-thumbnail="<?php echo $image_attributes[0]; ?>"></div>
    		                <div data-popup="<?php echo $image_attributes[0]; ?>" title="<?php the_title(); ?>"></div>
Viewing 1 replies (of 1 total)
  • Thread Starter burakakin

    (@burakakin)

    I have found my answer, This is the solution :

    <?php
    							$attachment_id = get_post_thumbnail_id($post->ID); // attachment ID
    
    							$image_attributes = wp_get_attachment_image_src( $attachment_id,'portfolio-item-resized' ); // returns an array
    							if( $image_attributes ) {
    							?> 
    
    		                <div data-width="240" data-height="161" data-thumbnail="<?php echo $image_attributes[0]; ?>"></div>
    		                <div data-popup="<?php echo $image_attributes[0]; ?>" title="<?php the_title(); ?>"></div>
    		                <?php } ?>
Viewing 1 replies (of 1 total)
  • The topic ‘how to use custom image size as html5 data’ is closed to new replies.