add data-attribute to all images inside the_content()

You will need to take a look at the image_send_to_editor filter. This will not update existing records but it if you get it working it will apply to each newly inserted image. very basic filter: function give_linked_images_class($html, $id, $caption, $title, $align, $url, $size, $alt=”” ){ $html; //contains the string you need to edit, you might … Read more

How can i alter the amount of different images sizes being stored?

Additional image sizes for uploaded images are created by wp_generate_attachment_metadata() after the file has been uploaded. An array of available sizes is populated using get_intermediate_image_sizes() (thumbnail, medium, large + custom sizes) which is later used to create the images. Both of the above functions have filters for overriding the sizes available to WordPress during this … Read more

Change website URL without breaking links or images? WP 3.3

There is a helpful codex article about moving WordPress: http://codex.wordpress.org/Moving_WordPress. Basically, you need to find/replace the DB for instances of your old domain, and swap them with your new domain. One additional trick I’ve learned when moving WordPress between environments: since WordPress stores the domain in several places as serialized data in the DB, you … Read more

Wrong domain in uploads folder

I will allow myself to expand on Ricks answer as there are a few ways to change old domain to new domain and each might be helpful depending on your situation. 1) use the Better Search and Replace plugin https://wordpress.org/plugins/better-search-replace/ plugin as suggested in the answer above. 2) use Database Search and Replace script https://interconnectit.com/products/search-and-replace-for-wordpress-databases/ … Read more

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