Skip to content

Commit

Permalink
save
Browse files Browse the repository at this point in the history
  • Loading branch information
crstauf committed Feb 7, 2024
1 parent b60c0f7 commit 312190b
Show file tree
Hide file tree
Showing 3 changed files with 393 additions and 6 deletions.
39 changes: 33 additions & 6 deletions Demo.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,6 @@ public static function instance() : self {
* Construct.
*/
protected function __construct() {
$this->theme = get_stylesheet();

add_action( 'template_redirect', array( $this, 'action__template_redirect' ), 101 );
}

Expand Down Expand Up @@ -65,8 +63,6 @@ public function action__template_redirect() : void {
return;
}

get_header();

$this->header();
$this->attachment();
$this->attachment_lqip();
Expand All @@ -76,6 +72,7 @@ public function action__template_redirect() : void {
$this->unsplash();
$this->placeholder();
$this->placehold();
$this->holderjs();
$this->url();
$this->fallback();

Expand All @@ -87,11 +84,13 @@ public function action__template_redirect() : void {
protected function header() : void {
?>

<html>
<html class="no-js">

<head>
<title>Image Tag demo</title>

<script>document.documentElement.className = document.documentElement.className.replace( 'no-js', 'js' );</script>

<style>

html, body {
Expand All @@ -100,6 +99,10 @@ protected function header() : void {
padding: 0;
}

html.no-js .hide-if-no-js {
display: none !important;
}

body,
figure {
display: flex;
Expand Down Expand Up @@ -144,6 +147,8 @@ protected function header() : void {
box-sizing: border-box;
}
</style>

<?php wp_head() ?>
</head>

<body>
Expand Down Expand Up @@ -322,6 +327,28 @@ protected function placehold() : void {
$this->output( $image, ob_get_clean() );
}

protected function holderjs() : void {
$image = \Image_Tag::create( 'holderjs', array(
'width' => 750,
'height' => 500,
), array(
'random' => true,
) );

ob_start();
?>

\Image_Tag::create( 'holderjs', array(
'width' => 750,
'height' => 500,
), array(
'random' => true,
) );

<?php
$this->output( $image, ob_get_clean() );
}

protected function url() {
$url = 'https://placehold.co/982x1424@2x.png';

Expand All @@ -334,7 +361,7 @@ protected function url() {
?>

\Image_Tag::create(
"<?php echo $url ?>",
'<?php echo $url ?>',
array(
'width' => 982,
'height' => 1424,
Expand Down
Loading

0 comments on commit 312190b

Please sign in to comment.