Search and replace image urls in posts

I coudn’t solve it with a plugin or plain SQL, see this other question. Instead I exported all the posts with Tools > Data export > WordPress and deleted the posts. Then I run this python script over the exported XML file and imported the update xml file again. Tadaa… import re p = re.compile(r’http://([^/]*)/getfile/files.posterous.com/([^/]*)/([^/]*)/([^/]*)’) … Read more

Thumb doubles the image file size

What you need to do is to compress the image. WordPress offers a filter to set the compression ratio. function my_jpg_compression($args) { return 75; } add_filter(‘jpeg_quality’, ‘my_jpg_compression’); NOTE: What you are returning is the compression ratio. 70-80% is manageable and you will not notice much reduced image quality. Also, after applying this filter only future … Read more

Getting featured image of blog page rather than post image

This code might be what you’re after. This loops through page templates to grab the featured image. If you add it outside the loop in your page.php template (or index.php, depending on your theme), it should grab the pages’ featured image, not the posts’. <?php global $post; if ( isset($post) ) { //get the ancestors … Read more

Setting name of attachment URL

You can hook onto add_attachment and force the slug to work off the filename like so: Update: To uppercase the slug, you’ll need to add a temporary filter onto wp_unique_post_slug. You can’t simply use strtoupper( $slug ) as WordPress sanitises (lowercases) it within the update function. /** * Force attachment slug to ignore title from … Read more

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