History Timelines
I build a site recently that contains a timeline and in my research for putting this feature together I found some interesting examples. I am putting this post here for my future reference and in the hope that you, dear reader, may also find these interesting.
Historical Tech Tree – A visualization of human technology
https://www.historicaltechtree.com/
Food Timeline – A history of human food
https://foodtimeline.org/
Convert directory of images on the command line
I had a need, well I always have a need but I finally got around to figuring this out, to resize a directory of images. I finally broke up with Adobe and had historically used the Photoshop batch functionality which was always wonky at best so that’s no longer possible. I’ve done some digging and discovered yet again that Linux just does everything better. So without further adieu the command:
$ mogrify -path ./webp_images/ -format webp -quality 80 -resize 1200x1200\> *.jpg
Everything here is straightforward aside from the ‘\>’ after the resize flag. This extra bit prevents smaller images from being upscaled. FYI, you’ll need imagemagick installed to run the mogrify command.
Extra credit, here’s a command to mogrify a directory of images no matter the file type:
for img in *.{jpg,jpeg,png,bmp}; do [ -e "$img" ] && mogrify -path ./webp_images/ -format webp -quality 80 -resize 1200x1200\> "$img" done
UPDATE:
Here’s another example that will loop over a directory recursively and resize without upscaling and save as WEBP.
find . -maxdepth 1 -type f \( -iname '*.jpg' -o -iname '*.png' -o -iname '*.jpeg' -o -iname '*.bmp' \) -exec mogrify -path ./webp_images/ -format webp -quality 80 -resize 1200x1200\> {} +
UPDATE 2:
Here’s another example, a shell script, that will loop over a directory, save as WEBP and change the file name to include the directory that the image was found in.
#!/bin/bash # --- Configuration --- # Set the base directory to search for images. "." means the current directory. SOURCE_DIR="." # Set the directory where processed images will be saved. # The ~ will be expanded to your home directory. OUTPUT_DIR=~/web_images # --------------------- # Create the output directory if it doesn't already exist. # The '-p' flag prevents errors if the directory is already there. echo "Ensuring output directory exists at $OUTPUT_DIR..." mkdir -p "$OUTPUT_DIR" # Use 'find' to locate all image files recursively and process them. echo "Starting image processing..." find "$SOURCE_DIR" -type f \( -iname "*.jpg" -o -iname "*.jpeg" -o -iname "*.png" -o -iname "*.bmp" \) -exec bash -c ' # This inline script is executed for each file found by `find`. # The full path of the found file (e.g., ./subdir/image.jpg) is passed as the first argument ($1). # The destination directory is passed as the second argument ($2). file="$1" output_dir="$2" # 1. Get the parent directory name (e.g., "subdir"). parent_dir=$(basename "$(dirname "$file")") # 2. Get the filename without its original extension (e.g., "image"). base_name_no_ext=$(basename "${file%.*}") # 3. Construct the new filename by prepending the parent directory name. # If the image is in the source directory itself (parent is "."), we dont prepend ".-". if [ "$parent_dir" = "." ] || [ "$parent_dir" = "$SOURCE_DIR" ]; then new_name="${base_name_no_ext}.webp" else new_name="${parent_dir}-${base_name_no_ext}.webp" fi # 4. Define the full output path for the new image. output_path="${output_dir}/${new_name}" echo "Processing: \"$file\" -> \"$output_path\"" # 5. Use "convert" to resize, set quality, and save to the new path and format. # "1200x1200>" resizes only if the image is larger than 1200px on either side. convert "$file" -resize "1200x1200>" -quality 80 "$output_path" ' bash {} "$OUTPUT_DIR" \; # This passes the filename and output directory to the inline script echo "✅ Done."Published on August 5, 2025
Me on a bike 2024
Converting Windows line endings to UNIX
Especially in the case of writing shell scripts. It’s imperative to move from CRLF (Win) to LF (*nix) so they will run.
Try this:
$ dos2unix FILE_NAME.EXT
if that doesn’t work, then try this.
$ sed -i 's/\r$//' FILE_NAME.EXT
Also, make sure you’ve set the permission bits so they can execute.
$ chmod 770 FILE_NAME.EXTPublished on September 3, 2024
Issue with register_post_type with custom capability type(s)
I have a plugin for a site that creates multiple custom post types (CPT). Each with their own custom capability specified via the capability_type
attribute of the register_post_type()
function. I copy-and-pasted the code block for each register_post_type()
from the first one, which includes the capability_type
as an array, ie. array('type' , 'types')
. Some of the subsequent CPT didn’t need multiple capability types so I was receiving the warning ‘Notice: Undefined offset: 1 in post.php’ due to a single item in the array. The fix was to remove the array wrapping the single value, et voila, no more warning.
Disable New User Notification Emails in WordPress
I use this when doing bulk imports of users in dev environments.
add_filter( 'wp_new_user_notification_email', '__return_false', 10, 3 );
Add that to functions.php
and you’re set. Users will not be notified.
Delete post revisions in WordPress with wp-cli
Easily remove revisions using wp-cli. First, get a list of revisions with:
$ wp post list --post_type='revision' --format=ids
This command will provide a list of revisions by post ID.
To remove those revisions, use to following command:
$ wp post delete $(wp post list --post_type='revision' --format=ids) --force
This command will provide feedback to stdout as Success: Deleted post XXX.
Where XXX is the post ID of the deleted post. The --force
flag may not be necessary, but was in my case since the command failed with the warning: Warning: Posts of type 'revision' do not support being sent to trash.
Me on a bike (Winter/Spring 2023)
CES Northstar Enduro – Truckee, CA
SET Redemption Enduro – Eureka Springs, AR
SET O’Rock Enduro – Ouachita National Forest, OK
SET Dino Enduro – Dinosaur State Park, Glen Rose, TX
SET Return of the Zombie Goat Enduro – Flat Rock Ranch, Comfort, TX
Published on January 24, 2023Me on a bike (Fall 2022)
TTP TEXAS ENDURO CUP – Spider Mountain, Burnet, TX
TTP TEXAS ENDURO CUP – Reveille Peak Ranch, Burnet, TX
Published on October 31, 2022