Using SRCSET with Images and Featured Images

Browsers which understand the srcset attribute will automatically choose the image which corresponds between the defined sizes and available space. Most of modern browsers support this, older browsers still found in the wild will gracefully fall back and simply use the image linked in the src attribute. There is no additional Javascript needed to activate, … Read more

renaming an image automatically everywhere else (posts and pages)

I did the same thing few days back. I took the post slug as image name for SEO purpose. I created a function to create/move images to a particular folder depending on the slug and input image url. Here is look of my function- function tb_get_image($image_ext_url,$slug,$upload_folder=””,$title=””){ $uri = WP_CONTENT_DIR.”/uploads/”.$upload_folder; $folder = WP_CONTENT_URL.”/uploads/”.$upload_folder; if(!file_exists($uri)){ $oldmask = … Read more

Auto delete attachments that are older than x days

Are you really sure you want to do this? What about all of the posts that these “old” attachments are used in? For attachments that are used for things like “featured image”, WP will take of that for you. However, for uses of an attachment in post_content, e.g. <img src=”https://wordpress.stackexchange.com/questions/258966/img_attachment_url” /> <a href=”pdf_attachment_url”>download PDF</a> you’ll … Read more