Remove rel=”attachment wp-att-XX”

You can remove it right before post is printed to the screen by stripping it out from content. But remember it still will meddle in Editor. <?php function my_remove_rel_attr($content) { return preg_replace(‘/\s+rel=”attachment wp-att-[0-9]+”/i’, ”, $content); } add_filter(‘the_content’, ‘my_remove_rel_attr’);

Why won’t these imported images show up?

I am assuming that WP takes the additional parameters at the end of the file name to automatically resize the image… WordPress adds those suffixes when it creates the images, which is typically done on image upload. Those images should be on the server. By default (and if I am not mistaken), WordPress does not … Read more

Remove images from get_the_excerpt

If you read the Codex entry for get_the_excerpt(), you will find this: If the post does not have an excerpt, this function applies wp_trim_excerpt to the post content and returns that generated string with “[…]” at the end. wp_trim_excerpt is applied via the get_the_excerpt filter and can be removed. The wp_trim_excerpt() function: Generates an excerpt … Read more

How to output placeholder image if no featured image set?

I think that you’re adding the code inside the loop of index.php or blog template file. You might be try this kind of things: if ( class_exists( ‘MultiPostThumbnails’ ) && ( MultiPostThumbnails::has_post_thumbnail( get_post_type(), ‘header-image’ , get_the_ID() ) ) ) { MultiPostThumbnails::the_post_thumbnail(get_post_type(), ‘header-image’, NULL, ‘header-image-full’, array(‘class’ => “custom-header-image”) ); } else { $image = get_template_directory_uri() .’/assets/img/placeholders/placeholder.png’; … Read more

Autogenerated Thumbnail compression depending on size

i’m looking for a more discrete and automatic approach. And that is altering the wp_create_thumbnail i think. And that is where you’d be wrong. Here is the entire code for wp_create_thumbnail() from core: function wp_create_thumbnail( $file, $max_side, $deprecated = ” ) { if ( !empty( $deprecated ) ) _deprecated_argument( __FUNCTION__, ‘1.2’ ); $thumbpath = image_resize( … Read more

Media gallery – inserting full size images without link

UPDATE I’ve just submitted a core patch to add link=”none” support to the shortcode. ORIGINAL ANSWER You don’t need to hack core to do what you want to do; just use the appropriate shortcode parameters, e.g.: If you want to change the defaults, then use the post_gallery filter: function mytheme_gallery_shortcode_defaults( $output, $attr ) { global … Read more

Disabling auto-resizing of uploaded images

To disable resizing for all image sizes without manually removing each size with remove_image_size function, use the filter intermediate_image_sizes_advanced /** * @param array $sizes An associative array of image sizes. * @param array $metadata An associative array of image metadata: width, height, file. */ function remove_image_sizes( $sizes, $metadata ) { return []; } add_filter( ‘intermediate_image_sizes_advanced’, … Read more