Skip to content

Instantly share code, notes, and snippets.

@henshaw
henshaw / coywolf-logo-srcset.html
Created March 30, 2025 17:06
Coywolf logo swap using the image srcset property
<picture>
<source media="(max-width: 39rem)" srcset="https://coywolf.pro/wp-content/themes/coywolf-v2/images/coywolf-white.svg" width="60" height="52">
<source media="(min-width: 40rem)" srcset="https://coywolf.pro/wp-content/themes/coywolf-v2/images/coywolf-horizontal-logo.svg" width="287" height="52">
<img src="https://coywolf.pro/wp-content/themes/coywolf-v2/images/coywolf-white.svg" loading="eager" alt="Paint color swatches" width="60" height="52">
</picture>
@henshaw
henshaw / perfect-palette-design.html
Created March 30, 2025 16:55
Perfect Palette Design using the image srcset property
<picture>
<source media="(max-width: 39rem)" srcset="interior-paint-consulting-mobile.webp" width="1200" height="1196">
<source media="(min-width: 40rem)" srcset="interior-paint-consulting-desktop.webp" width="1600" height="872">
<img src="interior-paint-consulting-desktop.webp" loading="lazy" alt="Interior paint swatches with a bed, rug, and pillow" width="1600" height="872">
</picture>
@henshaw
henshaw / srcset.html
Created March 30, 2025 16:02
Image with and without srcset in WordPress
<!-- Without srcset -->
<figure class="wp-block-image size-full">
<img decoding="async" width="1231" height="216" src="https://www.coywolf.news/wp-content/uploads/2025/03/open-in-app.webp" alt="Chrome Open in app button" class="wp-image-5157" />
<figcaption class="wp-element-caption">The prominent &#8220;Open in app&#8221; button in Chrome that opens installed PWAs</figcaption>
</figure>
<!-- With srcset -->
<figure class="wp-block-image size-full">
<img decoding="async" width="1231" height="216" src="https://www.coywolf.news/wp-content/uploads/2025/03/open-in-app.webp" alt="Chrome Open in app button" class="wp-image-5157" srcset="https://www.coywolf.news/wp-content/uploads/2025/03/open-in-app.webp 1231w, https://www.coywolf.news/wp-content/uploads/2025/03/open-in-app-300x53.webp 300w, https://www.coywolf.news/wp-content/uploads/2025/03/open-in-app-1024x180.webp 1024w, https://www.coywolf.news/wp-content/uploads/2025/03/open-in-app-768x135.webp 768w, https://www.coywolf.news/wp-content/uploads/2025/03/ope
@henshaw
henshaw / functions.php
Created October 10, 2024 02:27
This code, which goes in functions.php, forces WordPress to put jQuery links within the header.
function insert_jquery(){
wp_enqueue_script('jquery', false, array(), false, false);
}
add_filter('wp_enqueue_scripts','insert_jquery',1);
@henshaw
henshaw / manifest.json
Created October 6, 2024 17:18
Masked icons for PWA
{
"purpose": "maskable",
"sizes": "1024x1024",
"src": "/images/icons/maskable/maskable_icon.png",
"type": "image/png"
},
{
"purpose": "maskable",
"sizes": "512x512",
"src": "/images/icons/maskable/maskable_icon_x512.png",
@henshaw
henshaw / manifest.json
Created October 6, 2024 17:10
macOS icons for PWA manifest file
{
"purpose": "any",
"sizes": "1024x1024",
"src": "/images/[email protected]",
"type": "image/png"
},
{
"purpose": "any",
"sizes": "512x512",
"src": "/images/icon_512x512.png",
@henshaw
henshaw / apple-touch-icon.html
Created October 6, 2024 16:51
PWA icons for iOS and iPadOS
<link rel="apple-touch-icon" sizes="40x40" href="/images/icons/ios/Icon-Light-40x40.png">
<link rel="apple-touch-icon" sizes="58x58" href="/images/icons/ios/Icon-Light-58x58.png">
<link rel="apple-touch-icon" sizes="60x60" href="/images/icons/ios/Icon-Light-60x60.png">
<link rel="apple-touch-icon" sizes="76x76" href="/images/icons/ios/Icon-Light-76x76.png">
<link rel="apple-touch-icon" sizes="80x80" href="/images/icons/ios/Icon-Light-80x80.png">
<link rel="apple-touch-icon" sizes="87x87" href="/images/icons/ios/Icon-Light-87x87.png">
<link rel="apple-touch-icon" sizes="114x114" href="/images/icons/ios/Icon-Light-114x114.png">
<link rel="apple-touch-icon" sizes="120x120" href="/images/icons/ios/Icon-Light-120x120.png">
<link rel="apple-touch-icon" sizes="128x128" href="/images/icons/ios/Icon-Light-128x128.png">
<link rel="apple-touch-icon" sizes="136x136" href="/images/icons/ios/Icon-Light-136x136.png">
@henshaw
henshaw / google-web-cache.js
Created January 29, 2024 04:09
Bookmarklet URL for viewing a web page in Google's Web Cache
javascript: window.location = 'https://webcache.googleusercontent.com/search?q=cache:' + window.location.protocol + '//' + window.location.hostname + window.location.pathname;
@henshaw
henshaw / hide-label.css
Last active January 25, 2024 23:32
CSS for hiding the WordPress Search Form Label while maintaining accessiblity (not using display:none;)
.screen-reader-text:not(:focus):not(:active) {
position: absolute;
overflow: hidden;
clip: rect(0 0 0 0);
clip-path: inset(50%);
width: 1px;
height: 1px;
white-space:nowrap;
}
@henshaw
henshaw / open-graph-image.php
Created January 3, 2024 00:02
Open Graph Thumbnail Images for WordPress
if ( function_exists( 'add_theme_support' ) ) {
add_theme_support( 'post-thumbnails' );
set_post_thumbnail_size( 150, 79, true );
add_image_size( 'single-post-thumbnail', 1200, 630 );
}