Skip to content

Commit

Permalink
Refactor replaceCdnUrl for PHP 5.6 compatibility
Browse files Browse the repository at this point in the history
  • Loading branch information
Nichita committed Dec 9, 2024
1 parent 7feaff3 commit 662b4d2
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions editor/crop-cache-media.php
Original file line number Diff line number Diff line change
Expand Up @@ -244,15 +244,13 @@ private function getImgUrlByWpSize( $uid, $size ) {
* @param string $imgUrl The original image URL.
* @return string The updated image URL with the server domain and without query parameters.
*/
private function replaceCdnUrl(
string $imgUrl
): string {
private function replaceCdnUrl($imgUrl) {
$server_domain = site_url();

$parsed_url = parse_url($imgUrl);
$img_domain = $parsed_url['scheme'].'://'.$parsed_url['host'];

$path = $parsed_url['path'] ?? '';
$path = isset($parsed_url['path']) ? $parsed_url['path'] : '';

if ($img_domain !== $server_domain) {
$imgUrl = str_replace($img_domain, $server_domain, $img_domain.$path);
Expand Down

0 comments on commit 662b4d2

Please sign in to comment.