Versions
What's wrong?
In template_preprocess_field_slideshow()
, there is a specific execution path that can render the HTML output structure incorrectly. Here is an example of the erroneous output:
<div class='inner-slide'>
<img class="some_classes" src="some_path" alt="some_value" title="some_value2" /></diwidth="480" height />
Why is this happening?
There's a block of code in template_preprocess_field_slideshow()
that will guarantee a <div>
wrapper around the image.
if (isset($variables['image_style']) && $variables['image_style'] != '') {
$image['style_name'] = $variables['image_style'];
$image['breakpoints'] = $variables['breakpoints'];
$variables['items'][$num]['image'] = "<div class='inner-slide'>" . theme($slide_theme, $image) . "</div>";
} elseif (isset($variables['file_style']) && $variables['file_style'] != '') {
$media = file_view((object)$variables['items'][$num], $variables['file_style']);
$variables['items'][$num]['image'] = "<div class='inner-slide'>" . render($media) . "</div>";
} else {
$variables['items'][$num]['image'] = "<div class='inner-slide'>" . theme('image', $image) . "</div>";
}
There is a total of 3 possible execution paths here. No matter which path is taken, a <div>
wrapper is added.
Next, not too far down, we have this block of code:
if ($item["type"] == 'image' && strpos($variables['items'][$num]['image'], 'width=') === FALSE) {
$variables['items'][$num]['image'] = drupal_substr($variables['items'][$num]['image'], 0, -2) . "width=\"$dimensions[width]\" height=\"$dimensions[height]\" />";
}
This replaces the last 2 characters "v>" of </div>
with extra width and height info. And here it is assumed that the last 2 characters are "/>" belonging to the <img>
tag - which is not true.
Solution:
if ($item["type"] == 'image' && strpos($variables['items'][$num]['image'], 'width=') === FALSE) {
// $variables['items'][$num]['image'] = drupal_substr($variables['items'][$num]['image'], 0, -2) . "width=\"$dimensions[width]\" height=\"$dimensions[height]\" />";
$variables['items'][$num]['image'] = str_replace("<img ", "<img width=\"$dimensions[width]\" height=\"$dimensions[height]\" ", $variables['items'][$num]['image']);
}
Closed: outdated
Code
Not all content is available!
It's likely this issue predates Contrib.social: some issue and comment data are missing.