Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php // In order to give the right rich snippets required by google snippets validator
- if ( has_post_thumbnail() ) : // check if the post has a Post Thumbnail assigned to it.
- $upload_dir = wp_upload_dir();
- $size = 'large';
- $post_thumbnail_id = get_post_thumbnail_id( $post_id );
- $post_thumbnail_meta = wp_get_attachment_metadata ( $post_thumbnail_id );
- $main_file = $post_thumbnail_meta [ 'file' ];
- $dirname = dirname ( $main_file );
- $base_url = trailingslashit ( $upload_dir['baseurl'] ) . $dirname . '/';
- $filename = $post_thumbnail_meta [ 'sizes' ][ $size ][ 'file' ];
- $width = $post_thumbnail_meta [ 'sizes' ][ $size ][ 'width' ];
- $height = $post_thumbnail_meta [ 'sizes' ][ $size ][ 'height' ];
- $file = $base_url . $filename;
- ?>
- <div itemprop="image" itemscope itemtype="https://schema.org/ImageObject">
- <meta itemprop="url" content="<?php echo $file; ?>">
- <meta itemprop="width" content="<?php echo $width; ?>">
- <meta itemprop="height" content="<?php echo $height; ?>">
- <?php
- if ( has_post_thumbnail() ) {
- the_post_thumbnail( 'full', array('class'=>'post_thumbnail_common', 'alt' => get_the_title() , 'title' => get_the_title() ));
- echo contentnoimg(41);} else { echo content(41); } ?>
- </div>
- <?php
- endif;
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement