Tag Info

Hot answers tagged

3

here's the wp_get_attachment_image_scr function: function wp_get_attachment_image_src($attachment_id, $size='thumbnail', $icon = false) { // get a thumbnail or intermediate image if there is one if ( $image = image_downsize($attachment_id, $size) ) return $image; $src = false; if ( $icon && $src = ...


2

If you only want the size ( the width and the height ) of the image in the img tag like so <img src="source_of_your_image" width="500" height="250"/> Then use the following php code: $MySrc = "source_of_your_image"; $Myimg = "<img src='$MySrc' "; $TheImg = (array)getimagesize($MySrc); $Myimg .= $TheImg[3]."/>"; For more info on using ...


1

EXPLANATION As mentioned in my update above, to retrieve the ID of a thumbnail the get_post_meta function can be used without any additional DB overhead. The 'normal' way to get the url to a thumbnail id is with wp_get_attachment_image_src or similar functions, but those do not accept an array of IDs. What i noticed using wp_get_attachment_image_src was ...


1

You can collect image attributes using "wp_get_attachment_metadata", see below example as starting point function mytheme_post_thumbnail( $size = 'post-thumbnail', $attr = '', $post_id = null ) { if ( has_post_thumbnail( $post_id ) ) { $meta = wp_get_attachment_metadata( get_post_thumbnail_id( $post_id ) ); $args['width'] = ...


1

I normally use something like: if ( current_theme_supports('post-thumbnails') && has_post_thumbnail() ) { $post_thumb_id = get_post_thumbnail_id($id); $image_data = wp_get_attachment_image_src($post_thumb_id, 'thumbnail'); $attr_title = esc_attr($title); $image = <<<HTML <div class="thumbnail"><img ...


1

wp_get_attachment_image this function can help you. Using this function, your file should like below... entry-summary.php <?php the_title( '<h1 class="clear">', '</h1>' ); ?> <?php if ( has_post_thumbnail() ) { $attachment_id = get_post_thumbnail_id( get_the_ID() ); $default_attr = array( 'src' => $src, ...


1

2 Years later, there is a WordPress plugin that does this. Checkout "Featured Images for Categories" https://wordpress.org/plugins/featured-images-for-categories/


1

Simply use set_url_scheme() function. $share_image_src = wp_get_attachment_image_src( get_post_thumbnail_id(), 'large' ); $share_image_src = set_url_scheme( $share_image_src, 'http' );


1

By default post types "post" and "page" do have support for featured image meta box. You don't need to add some thing in function.php for that. This might be happening due to some plugin confliction. I would suggest try deactivating your plugins one by one and check if it gets back.


1

As I previously said in a comment You are using invalid values in get_previous_post() and get_next_post(). You are better of here writing your own function I came up with the following. : Get an array of all the posts and determine the current post's position. Get the post ID's of the posts on both sides of the current post. The amount of ID's ...



Only top voted, non community-wiki answers of a minimum length are eligible