joomla 3.6.5
Virtumart 3.2.1
Issue: Administrator area -> Virtuemart -> Products (or Categories) -> Editing product page, images tab
When there is no image in search results mediahandler functionality become broken. Illustration:
(https://thumb.ibb.co/ig2ArQ/Virtuemart_Mediahandler.png) (https://ibb.co/ig2ArQ)
Cause:In some cases json respons looks like simple strings instead of normal Json response.
1) Look in /administrator/components/com_virtuemart/
views/media/view.json.php line 65Quote$list = VmMediaHandler::displayImages($type,$start );
echo vmJsApi::safe_json_encode($list);
2) Look in /administrator/components/com_virtuemart/
helpers/mediahandler.phpline 987
Quote$Images = array();
$list = VmMediaHandler::getImagesList($types,$page,$max);
if (empty($list['images'])){
return vmText::_('COM_VIRTUEMART_NO_MEDIA_FILES');
}
So, function
displayImages should return
Array. But when no images found it returns
string. With "echo vmJsApi::safe_json_encode($list)" virtuemart response looks like simple string instead of Json structure ( "No Images Found" instead of something like "[{ "key":"value"}])
Thank you for the good explanation. Does it help to use
if (empty($list['images'])){
$Images[0]['label'] = vmText::_('COM_VIRTUEMART_NO_MEDIA_FILES');
$Images[0 ]['value'] = '';
return $Images;
}
Thanks!
Yes, it works but there is another 'bug':
When we reach last page of images and then "No images found" appears, buttons + / - pagination still works. And if you, for example, click 3 times on "+", you'll see "No images found" 3 time (it's ok). But now if you wanna back to images, you should press " - " 3+1 time, before you reach last images page ;D
It's because " + " buttons still active and script still sends requests "/index.php?.......&start=176", "&start=192", "&start=208" and getting response creates 3 page with "No images found" )
So script should disable "+" when response is empty
I hope you understand what I am talking about :D
Thanks!