Animated Gif as Featured Image

It is perfectly fine to use animated gifs in any capacity you like in WordPress, even as featured images. When you upload an image, WordPress will process it into various shapes and sizes, as specified by your theme and possibly some plugins as well. The version of image that gets displayed is determined by your … Read more

how to use first post image as thumbnail on wordpress

You can try this function, in your functions.php file. // automatically retrieve the first image from posts function get_first_image() { global $post, $posts; $first_img = ”; ob_start(); ob_end_clean(); $output = preg_match_all( ‘/<img .+src=[\'”]([^\'”]+)[\'”].*>/i’, $post->post_content, $matches ); $first_img = $matches[1][0]; if ( empty( $first_img ) ) { // defines a fallback imaage $first_img = get_template_directory_uri() . … Read more

How to print the thumbnail only if a post has a thumbnail

Try this inside else condition where no image assigned. if (has_post_thumbnail()) { ?><a href=”https://wordpress.stackexchange.com/questions/257634/<?php the_post_thumbnail_url(); ?>”> <?php the_post_thumbnail();?> </a><?php } else { echo ‘<figure><a href=”add_link_here”><img src=”‘.get_bloginfo(“stylesheet_directory”).’/images/stone.jpg” /></figure></a>’; }

How to automatically resize animated GIFs used as Featured Images, without losing animation?

A gif should work as a featured image. Upload the gif as the featured image and display on the post page (single.php) for example, using the following for the original size: the_post_thumbnail(‘full’); In the case of specific image sizes, i.e. <?php the_post_thumbnail( ‘custom-size’ ); ?> WP generates static images and in that case the gif … Read more

Set_post_thumbnail not resizing images

Setting the size itself does not crop the existing images. You need to regenerate the existing thumbnails too. There are a couple of plugins for this, but I personally downloaded and used Regenerate Thumbnails. Install the plugin, and head over to Tools > Regenerate Thumbnails. There you can regenerate thumbnails for images that exist in … Read more

post_thumbnail_html only for specific thumb size

You’re getting the size as the $size as the 4th argument of your callback function. You just need to use an if statement to check it: function thumb_bookmark_html( $html, $post_id, $post_image_id, $size ) { if ( $size === ‘thumb-bookmark’ ) { $html=”<a class=”MyClass” href=”” . get_permalink( $post_id ) . ‘” alt=”‘ . esc_attr( get_the_title( $post_id … Read more

If I Regenerate Thumbnails, would WordPress delete the existing Thumbnails and replace them with ‘new copies’?

Here’s what you can do: Delete the Old Thumbnails Download and install the Thumbnail Cleaner plugin. This plugin will delete all of your current thumbnails. You can do this manually by writing a PHP snippet that detects thumbnails and deletes them, but it’s not really that necessary. Resize the Original Images Once you have deleted … Read more

wordpress get_the_post_thumbnail can’t set size

1- In functions.php add_theme_support( ‘post-thumbnails’ ); add_image_size(‘my-custom-thumb’, 210, 210, true); 2- Note (https://codex.wordpress.org/Function_Reference/set_post_thumbnail_size) This function will not resize your existing featured images. To regenerate existing images in the new size, use the Regenerate Thumbnails (http://wordpress.org/plugins/regenerate-thumbnails/) plugin. 3- Then wp_get_attachment_image_src(get_post_thumbnail_id($id), ‘my-custom-thumb’) If that doesn’t work, then I would probably triple check if there is an image … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)