@@ -213,7 +213,7 @@ public static function get_demo_packages( $force = false ) {
213213 if ( $ force ) {
214214 delete_transient ( 'themegrill_demo_importer_demos ' );
215215 }
216- $ demos = get_transient ( 'themegrill_demo_importer_demos ' , array () );
216+ $ demos = get_transient ( 'themegrill_demo_importer_demos ' );
217217 if ( empty ( $ demos ) ) {
218218 $ need_fetch = true ;
219219 }
@@ -250,8 +250,10 @@ function ( $a, $b ) {
250250 set_transient ( 'themegrill_demo_importer_demos ' , $ demos , WEEK_IN_SECONDS );
251251
252252 } else {
253- // Transient was cached before apply_thumbnail_fallbacks existed; patch in-memory.
253+ // Apply any thumbnail URL migrations to cached data and persist so
254+ // subsequent requests don't need to re-apply.
254255 $ demos = static ::apply_thumbnail_fallbacks ( $ demos );
256+ set_transient ( 'themegrill_demo_importer_demos ' , $ demos , WEEK_IN_SECONDS );
255257 }
256258 $ data = static ::get_filtered_data ( $ demos , $ template );
257259 return apply_filters (
@@ -418,16 +420,30 @@ public static function apply_thumbnail_fallbacks( $demos ) {
418420 'online-shop-v2 ' => 'zakra-online-shop ' ,
419421 'restro-v2 ' => 'zakra-restro ' ,
420422 ),
421- 'colormag ' => array (),
423+ 'colormag ' => array (
424+ 'colormag ' => 'colormag-free ' ,
425+ 'colormag-01 ' => 'colormag-free-01 ' ,
426+ 'colormag-02 ' => 'colormag-free-02 ' ,
427+ ),
422428 );
423429
424430 foreach ( $ demos as $ demo ) {
425- if ( ! empty ( $ demo ->previewImage ) ) {
431+ $ theme = $ demo ->theme_slug ;
432+ $ folder = $ overrides [ $ theme ][ $ demo ->slug ] ?? $ demo ->slug ;
433+ $ gh_url = $ new_base . '/resources/ ' . $ theme . '/ ' . $ folder . '/screenshot.jpg ' ;
434+
435+ // Always expose the correct GitHub URL so the frontend can use it as a fallback.
436+ $ demo ->githubImage = $ gh_url ;
437+
438+ if ( empty ( $ demo ->previewImage ) ) {
439+ $ demo ->previewImage = $ gh_url ;
440+ } elseif ( false !== strpos ( $ demo ->previewImage , $ old_base ) ) {
441+ // Discontinued CloudFront CDN — swap base, keep path.
426442 $ demo ->previewImage = str_replace ( $ old_base , $ new_base , $ demo ->previewImage );
427- } else {
428- $ theme = $ demo -> theme_slug ;
429- $ folder = $ overrides [ $ theme ][ $ demo -> slug ] ?? $ demo -> slug ;
430- $ demo ->previewImage = $ new_base . ' /resources/ ' . $ theme . ' / ' . $ folder . ' /screenshot.jpg ' ;
443+ } elseif ( false !== strpos ( $ demo -> previewImage , ' themegrilldemos.com ' ) ) {
444+ // Use GitHub directly; letting the browser try themegrilldemos.com first
445+ // causes a slow timeout on every image before the fallback kicks in.
446+ $ demo ->previewImage = $ gh_url ;
431447 }
432448 }
433449
0 commit comments