Merge pull request #1497 from basteyy/fix_1496

Fix Deprecated message
This commit is contained in:
Diego Najar 2023-02-22 22:49:00 +01:00 committed by GitHub
commit a4654ce0ae
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 15 additions and 12 deletions

View file

@ -774,11 +774,11 @@ class SimpleImage {
/**
* Resize an image to the specified dimensions. If only one dimension is specified, the image will be resized proportionally.
*
* @param integer $width The new image width.
* @param integer $height The new image height.
* @param int|null $width The new image width.
* @param int|null $height The new image height.
* @return \claviska\SimpleImage
*/
public function resize($width = null, $height = null) {
public function resize(?int $width, ?int $height) {
// No dimentions specified
if(!$width && !$height) {
return $this;
@ -786,12 +786,12 @@ class SimpleImage {
// Resize to width
if($width && !$height) {
$height = $width / $this->getAspectRatio();
$height = (int)$width / $this->getAspectRatio();
}
// Resize to height
if(!$width && $height) {
$width = $height * $this->getAspectRatio();
$width = (int)$height * $this->getAspectRatio();
}
// If the dimensions are the same, there's no need to resize
@ -802,7 +802,7 @@ class SimpleImage {
// We can't use imagescale because it doesn't seem to preserve transparency properly. The
// workaround is to create a new truecolor image, allocate a transparent color, and copy the
// image over to it using imagecopyresampled.
$newImage = imagecreatetruecolor($width, $height);
$newImage = imagecreatetruecolor((int)$width, (int)$height);
$transparentColor = imagecolorallocatealpha($newImage, 0, 0, 0, 127);
imagecolortransparent($newImage, $transparentColor);
imagefill($newImage, 0, 0, $transparentColor);
@ -810,8 +810,8 @@ class SimpleImage {
$newImage,
$this->image,
0, 0, 0, 0,
$width,
$height,
(int)$width,
(int)$height,
$this->getWidth(),
$this->getHeight()
);

View file

@ -663,8 +663,8 @@ class Page {
$past = new DateTime($this->getValue('dateRaw'));
$elapsed = $current->diff($past);
$elapsed->w = floor($elapsed->d / 7);
$elapsed->d -= $elapsed->w * 7;
$weeks = floor($elapsed->d / 7);
$elapsed->d -= $weeks * 7;
$string = array(
'y' => $language->g('year'),
@ -677,8 +677,11 @@ class Page {
);
foreach ($string as $key => &$value) {
if ($elapsed->$key) {
$value = $elapsed->$key . ' ' . $value . ($elapsed->$key > 1 ? 's' : ' ');
$handle_type = 'w' === $key ? $weeks : $elapsed->$key;
if ($handle_type) {
$value = $handle_type . ' ' . $value . ($handle_type > 1 ? 's' : ' ');
} else {
unset($string[$key]);
}