Find posts without featured image? [duplicate]

You can use this plugin https://wordpress.org/plugins/quick-featured-images/ In description it says “You can also see posts with no featured image at a glance.” But from code side, wordpress manages images, documents any media by creating an attachment post for holding the information about that media and it’s relation (if any) with other post/posts, which means you … Read more

Setup A Default Featured Image

One simple method is to filter post_thumbnail_html, to add in a default image link: <?php function wpse55748_filter_post_thumbnail_html( $html ) { // If there is no post thumbnail, // Return a default image if ( ” == $html ) { return ‘<img src=”‘ . get_template_directory_uri() . ‘/images/default-thumbnail.png” width=”150px” height=”100px” class=”image-size-name” />’; } // Else, return the … Read more

Remove the http protocol from images

The code you provided could cause issues with 3rd party URLs in hyperlinks not running https. You can fix this by including your home url, e.g: $content = str_replace( set_url_scheme( home_url(), ‘http’ ), set_url_scheme( home_url(), ‘relative’ ), $content); Next, you’re applying this when you’d like to display the content, which means you need to do … Read more

Featured Image Size

For post thumbnails you can either crop and image to the thumbnail size or scale the image. To enable crop you can call the thumbnail 1 of 2 ways. Name a size in the functions.php file like so: <?php add_image_size( ‘my-post-thumbnail’, 494, 168, true ); ?> and then call it in the theme file <?php … Read more

Limit author image size

WordPress automatically resizes uploads into different formats based on the settings on the Settings » Media page: You can set up all of your different default sizes here. Though keep in mind that plug-ins and themes can define their own custom image sizes … so I can’t guarantee perfect operability in all cases.

How to get an image transferred via FTP or script to appear in Media Manager?

add this to your for each and $filename to each file, $wp_filetype = wp_check_filetype(basename($filename), null ); $attachment = array( ‘post_mime_type’ => $wp_filetype[‘type’], ‘post_title’ => preg_replace(‘/\.[^.]+$/’, ”, basename($filename)), ‘post_content’ => ”, ‘post_status’ => ‘inherit’ ); $attach_id = wp_insert_attachment( $attachment, $filename, 0 ); // you must first include the image.php file // for the function wp_generate_attachment_metadata() to … Read more

How to add an image for unit testing?

I’d take a look at how WordPress has constructed their attachment tests. You’ll find that tests/phpunit/tests/post/attachments.php they use this method: function _make_attachment( $upload, $parent_post_id = 0 ) { $type=””; if ( !empty($upload[‘type’]) ) { $type = $upload[‘type’]; } else { $mime = wp_check_filetype( $upload[‘file’] ); if ($mime) $type = $mime[‘type’]; } $attachment = array( ‘post_title’ … Read more