Please move these lines to the client and make all images available to the view that are either associated to the last catalog item or to one of the catalog items before if the last one contains no images