Probleem met toevoegen srcset function op lijn 252
Door
johannes davidian
op 18-05-2020 13:05
gewijzigd op 18-05-2020 13:50
2.875 views
Hallo,
ik probeer om srcset function toe te voegen in mij theme maar ik krijg foutmelding op lijn 252. ik probeerde om uit te vinden maar is niet gelukt.
deze is de code:
// Class
$class = implode(' ', apply_filters('john_img_class', $class));
if (!empty($class)) {
$class = 'class="' . esc_attr($class) . '"';
}
// Aspect ratio
$ratio = john_sizes_ratio($width, $height);
if (!empty($ratio)) {
$ratio = 'data-aspect-ratio="' . esc_attr($ratio) . '"';
}
// Attributes
$attributes = implode(' ', apply_filters('john_img_attributes', array('id' => 'id="wp-image-' . esc_attr($id) . '"', 'data-id' => 'data-id="' . esc_attr($id) . '"', 'class' => $class, 'ratio' => $ratio, 'schema' => 'itemprop="contentUrl"', 'alt' => 'alt="' . $alt . '"')));
// Return an array with the final width/height so these values can be passed up to the wrapper element for certain CSS styling tricks
return array(apply_filters('john_img', '<img ' . apply_filters('john_src_html', $src) . apply_filters('john_srcset_html', $srcset) . apply_filters('john_sizes_html', $sizes) . apply_filters('john_dimensions', image_hwstring($width, $height), $width, $height) . $attributes . '>'), $width, $height);
waar het kan de fout zijn , ik kunde niet vinden?
dank u wel
johannes
de fout melding is :
jouw PHP-wijzigingen zijn teruggedraaid vanwege een fout op regel 252 in het bestand wp-content/themes/john/functions.php. Repareer en probeer opnieuw.
<?php
// Class
$class = implode(' ', apply_filters('john_img_class', $class));
if (!empty($class)) {
$class = 'class="' . esc_attr($class) . '"';
}
// Aspect ratio
$ratio = john_sizes_ratio($width, $height);
if (!empty($ratio)) {
$ratio = 'data-aspect-ratio="' . esc_attr($ratio) . '"';
}
// Attributes
$attributes = implode(' ', apply_filters('john_img_attributes', array('id' => 'id="wp-image-' . esc_attr($id) . '"', 'data-id' => 'data-id="' . esc_attr($id) . '"', 'class' => $class, 'ratio' => $ratio, 'schema' => 'itemprop="contentUrl"', 'alt' => 'alt="' . $alt . '"')));
// Return an array with the final width/height so these values can be passed up to the wrapper element for certain CSS styling tricks
return array(apply_filters('john_img', '<img ' . apply_filters('john_src_html', $src) . apply_filters('john_srcset_html', $srcset) . apply_filters('john_sizes_html', $sizes) . apply_filters('john_dimensions', image_hwstring($width, $height), $width, $height) . $attributes . '>'), $width, $height);
?>
Waarom plaats je het nou steeds tussen quote-tags? Ik heb er nu weer code-tags van gemaakt, maar let daar graag in het vervolg op. Quote is voor andere zaken bedoeld.
Nog steeds zijn we benieuwd wat je aangepast hebt? Wat is die bewuste lijn? Enkel een code dumpen heeft niet veel nut namelijk.
Volgens mij vergeet je een accolade, je opent op regel 204 een accolade maar volgens mij sluit je deze niet. Ik vermoed namelijk dat de return nog in de functie behoort.