Skip to content
This repository has been archived by the owner on Aug 14, 2023. It is now read-only.

Replaces use of deprecated each function to improve PHP7 compatibility #14

Merged
merged 5 commits into from
Sep 20, 2019
Merged
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 17 additions & 14 deletions site/addons/Imgix/ImgixTags.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,17 +21,18 @@ protected function categorizedAttributes() {

unset($attrs['path']);

while (list($key, $val) = each($attrs)) {
$is_html_attr = in_array($key, self::$html_attributes);
$is_data_attr = strpos($key, 'data-') === 0;
$is_aria_attr = strpos($key, 'aria-') === 0;

if ($is_html_attr || $is_data_attr || $is_aria_attr) {
$categorized_attrs['img_attributes'][$key] = $val;
} else {
$categorized_attrs['imgix_attributes'][$key] = $val;
}
}
if (is_array($attrs)) {
foreach ($attrs as $key => $val) {
$is_html_attr = in_array($key, self::$html_attributes);
$is_data_attr = strpos($key, 'data-') === 0;
$is_aria_attr = strpos($key, 'aria-') === 0;
if ($is_html_attr || $is_data_attr || $is_aria_attr) {
$categorized_attrs['img_attributes'][$key] = $val;
sherwinski marked this conversation as resolved.
Show resolved Hide resolved
} else {
$categorized_attrs['imgix_attributes'][$key] = $val;
}
}
}

return $categorized_attrs;
}
Expand All @@ -48,9 +49,11 @@ protected function buildHtmlAttributes($categorized_attrs) {

$html = '';

while (list($key, $val) = each($img_attributes)) {
$html .= " $key=\"$val\"";
}
if (is_array($img_attributes)) {
foreach ($img_attributes as $key => $val) {
$html .= " $key=\"$val\"";
}
}

return $html;
}
Expand Down