madeyourday / contao-rocksolid-slider

RockSolid Slider Contao Extension
http://rocksolidthemes.com/de/contao/plugins/responsive-slider
Other
9 stars 7 forks source link

Meta attribute "title" not set in image within a slider type "content" #68

Closed Enrica-r closed 4 years ago

Enrica-r commented 4 years ago

Images can be used in slider type image or content. While slider type image sets attribute "title" from "$meta['title']" correctly this is missing in images from slider type content.

Both uses method "$this->addImageToTemplate()" (in line 224 for content slider, line 445 for image slider in "module/slider.php"). As you can see in line 457 the model "\FilesModel::findByPk($file->id)" of image is transfered as a parameter. Meta data is part of this object. In line 224 same parameter is missing. That's why meta data are not loaded for images in a content slider.

Please correct line 224 as follows:

$this->addImageToTemplate($newImage, $image, null, null, \FilesModel::findByPk($image['id']));

Thank you very much.

ausi commented 4 years ago

How should the line 224 be changed? Your code snippet is exactly the same as the current version:
https://github.com/madeyourday/contao-rocksolid-slider/blob/v2.0.15/src/Module/Slider.php#L224

Enrica-r commented 4 years ago

Hello Martin I have mistaken the line numbers. 224 is correct. In 445- 454 you handover the meta data in the array. But these are ignored in method "addImageToTemplate". I have added the "FilesModel" in 445, see:

$this->addImageToTemplate($slide['image'], array(
  'id' => $file->id,
  'name' => $fileObject->basename,
  'singleSRC' => $file->path,
  'alt' => $meta['alt'],
  'title' => $meta['title'],
  'imageUrl' => $meta['link'],
  'caption' => $meta['caption'],
  'size' => isset($this->imgSize) ? $this->imgSize : $this->size,
  ),
  null,
  null,
  \FilesModel::findByPk($file->id)
);

I don't have tested if all array elements are necessary. According to line 224 probably not.

Regards, Enrica

ausi commented 4 years ago

Please check if the changes from 8925992cb6f9ce0987000c08e49d576faca10714 fixes your issue.

Enrica-r commented 4 years ago

@ausi Yes, the fix 8925992 works perfectly. Thank you very much.