Tag: Images


Get a WordPress Image’s Attachment ID from its URL with a PHP Function from Pippin Williamson

pippin's plugins | retrieve image id from url
EDIT: As the comments below have pointed out, WordPress in later versions contains the attachment_url_to_postid() function, which is designed to do the job of the code below. However, on at least one project I’ve worked on (a WordPress multisite), WordPress’s function didn’t work and Pippin’s did. I’d try the WordPress function first and Pippin’s as a fallback.

You know who’s really great? Pippin Williamson.


Adding and Using WordPress Custom Image Sizes: A Guide to the Best Thing Ever

wordpress custom image sizes lol
Update April 4, 2017: Added a section detailing how the responsive image system in WordPress 4.4+ works, and how WordPress custom image sizes interact with this system.

I really love being able to set custom image sizes in WordPress. The power and flexibility this system opens up for building beautiful, easy-to-administer, performant websites is hard to overstate.



Automatic Lossless Compression for WordPress Images with the TinyPNG Plugin

tinypng wordpress plulgin

I’ve loved TinyPNG for a long time, but didn’t realize until quite recently that they’ve got a WordPress plugin. I just tried it on a client’s site, and it’s amazing: automatic lossless image compression for all .jpg and .png images uploaded through the Media uploader. That means that all your images are exactly the same, but have smaller filesizes.


Rename Your Media Files with… …Rename Media Files

It’s a bit odd that WordPress doesn’t let you rename your media files. For a feature with some usability questions and a lot of SEO questions (Google, of course, reads the filenames of images as a clue to what they’re about), it’s surprising that WordPress’s best out-of-the-box solution is to simply delete and reupload whatever files you’d like to have renamed.



Commonsense Image Sizing in WordPress

Large painting | WordPress image sizes

Here we’ll be discussing basic best practices for working with image sizes in WordPress. This has such a huge impact on site speed that it’s important to know the fundamentals. Playing around with caching and CDNs and everything is really great, but if an image on the page is 400KB bigger than it should be, to a large extent you’re back where you started.