public function loadFeaturedCollections($type_id) { $data = Collection::getFrontend($type_id); $arrFeaturedCollection = array(); foreach ($data as $value) { $width = $height = 0; $path = '/assets/images/noimage/315x165.gif'; if (!empty($value['image'])) { if ($value['image']['ratio'] > 1) { $width = 450; $height = $width / $value['image']['ratio']; } else { $height = 450; $width = $height * $value['image']['ratio']; } $path = '/pic/newcrop/' . $value['image']['short_name'] . '-' . $value['image']['id'] . '.jpg'; } $arrFeaturedCollection[] = ['collection_id' => $value['id'], 'collection_name' => $value['name'], 'collection_short_name' => $value['short_name'], 'width' => $width, 'height' => $height, 'path' => $path]; } if (Request::ajax()) { $html = View::make('frontend.types.featured-collections')->with('arrFeaturedCollection', $arrFeaturedCollection)->render(); $arrReturn = ['status' => 'ok', 'message' => '', 'html' => $html]; $response = Response::json($arrReturn); $response->header('Content-Type', 'application/json'); return $response; } return View::make('frontend.types.featured-collections')->with('arrFeaturedCollection', $arrFeaturedCollection)->render(); }