This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function convertWebPImages( $directory = '.' ){ | |
$files = glob( $directory . '/*.webp' ); | |
foreach( $files as $file ){ | |
$original_file = substr( $file, 0, -5 ); | |
$original_ext = pathinfo( $original_file, PATHINFO_EXTENSION ); | |
if( ! file_exists( $original_file ) ){ | |
$webp = imagecreatefromwebp( $file ); | |
if( $webp !== false ){ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
# this will create new .format() function for Date object | |
# there is auto localization from Intl, but you can also set language as a 2nd argument | |
# all possible values were tested and compared on Apache server with PHP 8 date() function | |
# you can find minified version in the first comment | |
# examples: | |
new Date().format('d.m.Y H:i:s') // 25.07.2022 09:11 |