Reindex an Array in PHP

Occasionally, you may need to arbitrarily reindex an array of data in PHP. WordPress doesn’t really provide a function for doing this, so I put together this code snippet.

Require a Featured Image in WordPress

The visual aspects of a site are important and many themes depend on the ‘Featured Image’ functionality in WordPress to provide a better visual experience. So, it only makes sense that you may want to consider requiring a featured image before a post can be published.

Get Attachment ID from a WordPress Image URL

Taking a WordPress image URL and using it to get the attachment ID is a bit tricky. There are a lot of code samples out there that do this, but they all have problems to some degree or another. Pippin Williamson posted a very elegant solution based on comparing the URL to the guid in… Read More

Remove Image Size Attributes for Responsive Images in WordPress

WordPress, by default, will add the width and height attributes to image elements. These attributes will override CSS width and height properties. Making images with these dimension attributes responsive is a bit of a hassle, or in some cases cannot be done at all. Strip Image Dimension Attributes from Inserted Images Stripping out the image… Read More

Tweaking WordPress Image Quality

Optimizing images for use on the web can significantly reduce page load times for image-heavy websites. What many people don’t realize is that WordPress automatically applies a 90% quality level to all JPEG images. This helps to conserve disk space and reduce bandwidth. However, if you are optimizing your images before you upload them, you… Read More

Use Self-Executing JavaScript Functions for Code Isolation

When you first start learning JavaScript, you focus on getting down the basics. Then, after you work with JavaScript for a while, you learn more about variable scoping and the importance of isolating and protecting your code from outside influences. What is variable scoping? Variable scope refers to the context within which a variable is… Read More

Breakpoint Aware JavaScript for Responsive Design

Supporting responsive design across all the handheld devices that are available today means that most websites use CSS media queries to set break points; typically for mobile, tablet and desktop. When JavaScript interactions come into play, sometimes your JavaScript code should be aware of the break points available in CSS. The code below allows you… Read More