Skip to content

background picture support#3

Open
jvega wants to merge 3 commits intocatch-IT:mainfrom
jvega:background-image
Open

background picture support#3
jvega wants to merge 3 commits intocatch-IT:mainfrom
jvega:background-image

Conversation

@jvega
Copy link
Copy Markdown

@jvega jvega commented May 27, 2024

Hi, I added background support.

Should be implemented with custom template bg_picture.html.twig

Comment thread image-server.php
Comment on lines +256 to 261
$parsedValue = match ($attr['name']) {
'width', 'height' => str_contains($attr['value'], '%') ? $attr['value'] : intval($attr['value']),
default => htmlspecialchars_decode($attr['value'], ENT_COMPAT),
};
${$attr['name']} = $parsedValue;
}
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

also I fix an issue when an IMG tag has defined the attribute width lower than image width

Comment thread image-server.php
->setActualCacheDir($cacheDir);
$image->zoomCrop($width, $height);
return str_replace($cacheDir, 'images', $image->cacheFile($format, $quality));
return str_replace($cacheDir, '/images', $image->cacheFile($format, $quality));
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

and this fix when the site has nested pages

Comment thread image-server.php


private function generatePictureMarkup($file, string $alt = '', ?float $ratio = null, ?array $breakpoints = null, ?int $maxWidth = null, ?string $loading = null, ?string $class = null, ?string $title = null, ?array $densitySet = null): string
private function generatePictureMarkup($file, string $alt = '', ?float $ratio = null, ?array $breakpoints = null, ?int $maxWidth = null, ?string $loading = null, ?string $class = null, ?string $title = null, ?array $densitySet = null, ?string $style = null): string
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

support style attribute

Comment thread image-server.php
Comment on lines +171 to +173
if (str_contains($file, '?')){
[$file] = explode('?', $file);
}
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fix when image has querystring

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

1 participant