fix: optimize CHRNX editorial media

This commit is contained in:
chrnx committed 2026-08-12 15:52:53 -05:00
1 parent 55e21bca81
commit c5720b21ca
14 files changed
+252 -46

No files matched your search

+21 -7
View File
@@ -91,6 +91,7 @@ test( 'the page canvas is atmospheric rather than a repeating grid', () => {
test( 'lower home sections preserve editorial order and define layered panel treatments', () => {
const front = read( 'templates/front-page.html' );
const homeMusic = read( 'patterns/home-music.php' );
const components = read( 'assets/css/components.css' );
const orderedSections = [
'chrnx/home-projects',
@@ -107,13 +108,12 @@ test( 'lower home sections preserve editorial order and define layered panel tre
previousIndex = currentIndex;
}
assert.match( homeMusic, /chrnx_get_topic_portrait_markup\( 'music-collage'/ );
assert.match( homeMusic, /chrnx-home-music__collage-layer/ );
assert.doesNotMatch( components, /url\([^)]*the-no-names-collage\.jpeg/ );
assert.match(
components,
/\.chrnx-home-music \.wp-block-columns::before\s*\{[\s\S]*?the-no-names-collage\.jpeg/,
);
assert.match(
components,
/\.chrnx-home-music \.chrnx-responsive-portrait\s*\{[\s\S]*?(?:filter|box-shadow|mask(?:-image)?):/,
/\.chrnx-home-music \.wp-block-column:last-child \.chrnx-responsive-portrait\s*\{[\s\S]*?(?:filter|box-shadow|mask(?:-image)?):/,
);
for ( const selector of [
'.chrnx-home-projects',
@@ -146,8 +146,18 @@ test( 'all approved portraits rebuild byte-identically within payload bounds', (
assert.deepEqual( readdirSync( external ), [ 'sentinel' ] );
execFileSync( './scripts/build-responsive-images.sh', [ output ], { cwd: new URL( '../..', import.meta.url ) } );
const names = readdirSync( output ).sort();
assert.equal( names.length, 35 );
assert.equal( names.length, 40 );
for ( const name of [
'the-no-names-collage-384.avif',
'the-no-names-collage-384.webp',
'the-no-names-collage-768.avif',
'the-no-names-collage-768.webp',
'the-no-names-collage.json',
] ) {
assert.ok( names.includes( name ), `missing ${ name }` );
}
let total = 0;
let collageTotal = 0;
for ( const name of names ) {
const generated = readFileSync( join( output, name ) );
const committed = readFileSync( new URL( `../../assets/images/generated/${ name }`, import.meta.url ) );
@@ -165,9 +175,13 @@ test( 'all approved portraits rebuild byte-identically within payload bounds', (
assert.equal( generated.subarray( 4, 12 ).toString(), 'ftypavif' );
}
total += generated.length;
if ( name.startsWith( 'the-no-names-collage-' ) ) {
collageTotal += generated.length;
}
}
}
assert.ok( total <= 1.7 * 1024 * 1024, `derivatives exceed 1.7 MiB: ${ total }` );
assert.ok( collageTotal <= 400 * 1024, `collage derivatives exceed 400 KiB: ${ collageTotal }` );
assert.ok( total <= 2.1 * 1024 * 1024, `derivatives exceed 2.1 MiB: ${ total }` );
} finally {
rmSync( output, { recursive: true, force: true } );
rmSync( external, { recursive: true, force: true } );