本文整理汇总了PHP中CUtil::DISP_IMAGE方法的典型用法代码示例。如果您正苦于以下问题:PHP CUtil::DISP_IMAGE方法的具体用法?PHP CUtil::DISP_IMAGE怎么用?PHP CUtil::DISP_IMAGE使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CUtil
的用法示例。
在下文中一共展示了CUtil::DISP_IMAGE方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: uploadCategoryImage
public function uploadCategoryImage($file, $image_ext, $image_name, $destinationpath, $reference_id, $mode)
{
$return_arr = array();
$config_path = \Config::get('webshoppack::product_category_image_folder');
CUtil::chkAndCreateFolder($config_path);
// open file a image resource
\Image::make($file->getRealPath())->save(\Config::get("webshoppack::product_category_image_folder") . $image_name . '_O.' . $image_ext);
list($width, $height) = getimagesize($file);
list($upload_img['width'], $upload_img['height']) = getimagesize(base_path() . '/public/' . $config_path . $image_name . '_O.' . $image_ext);
$thumb_width = \Config::get("webshoppack::product_category_image_thumb_width");
$thumb_height = \Config::get("webshoppack::product_category_image_thumb_height");
if (isset($thumb_width) && isset($thumb_height)) {
$timg_size = CUtil::DISP_IMAGE($thumb_width, $thumb_height, $upload_img['width'], $upload_img['height'], true);
\Image::make($file->getRealPath())->resize($thumb_width, $thumb_height, true, false)->save($config_path . $image_name . '_T.' . $image_ext);
}
$img_path = base_path() . '/public/' . $config_path;
list($upload_input['thumb_width'], $upload_input['thumb_height']) = getimagesize($img_path . $image_name . '_T.' . $image_ext);
if ($mode == 'edit') {
$this->deleteExistingImageFiles($reference_id);
}
$return_arr = array('image_ext' => $image_ext, 'image_name' => $image_name, 'image_width' => $upload_input['thumb_width'], 'image_height' => $upload_input['thumb_height']);
return $return_arr;
}
示例2: postProductActions
public function postProductActions()
{
$action = \Input::get('action');
$p_id = \Input::get('product_id');
switch ($action) {
case 'save_product_thumb_image_title':
$title = \Input::get('product_image_title');
echo $this->productService->saveProductImageTitle($p_id, 'thumb', $title) ? 'success' : 'error';
$this->productService->updateProductStatus($p_id, 'Draft');
exit;
break;
case 'save_product_default_image_title':
$title = \Input::get('product_image_title');
echo $this->productService->saveProductImageTitle($p_id, 'default', $title) ? 'success' : 'error';
$this->productService->updateProductStatus($p_id, 'Draft');
exit;
break;
case 'upload_product_thumb_image':
$title = \Input::get('product_image_title');
$this->productAddService->product_media_type = 'image';
$this->productAddService->setAllowedUploadFormats('thumb');
$this->productAddService->setMaxUploadSize('thumb');
$file_info = array();
$file = \Input::file('uploadfile');
$upload_file_name = $file->getClientOriginalName();
$upload_status = $this->productAddService->uploadMediaFile('uploadfile', 'image', $file_info);
if ($upload_status['status'] == 'success') {
$this->productService->updateItemProductImage($p_id, $title, $file_info);
$image_dim = CUtil::DISP_IMAGE(145, 145, $file_info['t_width'], $file_info['t_height'], true);
echo json_encode(array('status' => 'success', 'server_url' => $file_info['server_url'], 'filename' => $file_info['filename_no_ext'] . 'T.' . $file_info['ext'], 't_width' => $image_dim['width'], 't_height' => $image_dim['height'], 'title' => $file_info['title']));
$this->productService->updateProductStatus($p_id, 'Draft');
} else {
echo json_encode(array('status' => 'error', 'error_message' => $upload_status['error_message'], 'filename' => $upload_file_name));
}
exit;
break;
case 'upload_item_default_image':
$title = \Input::get('product_image_title');
$this->productAddService->product_media_type = 'image';
$this->productAddService->setAllowedUploadFormats('default');
$this->productAddService->setMaxUploadSize('default');
$file_info = array();
$file = \Input::file('uploadfile');
$upload_file_name = $file->getClientOriginalName();
$upload_status = $this->productAddService->uploadMediaFile('uploadfile', 'image', $file_info);
if ($upload_status['status'] == 'success') {
$this->productService->updateProductDefaultImage($p_id, $title, $file_info);
$image_dim = CUtil::DISP_IMAGE(578, 385, $file_info['l_width'], $file_info['l_height'], true);
echo json_encode(array('status' => 'success', 'server_url' => $file_info['server_url'], 'filename' => $file_info['filename_no_ext'] . 'L.' . $file_info['ext'], 't_width' => $image_dim['width'], 't_height' => $image_dim['height'], 'title' => $file_info['title']));
$this->productService->updateProductStatus($p_id, 'Draft');
} else {
echo json_encode(array('status' => 'error', 'error_message' => $upload_status['error_message'], 'filename' => $upload_file_name));
}
exit;
break;
case 'remove_default_thumb_image':
echo $this->productService->removeProductThumbImage($p_id) ? 'success' : 'error';
$this->productService->updateProductStatus($p_id, 'Draft');
exit;
break;
case 'remove_default_image':
echo $this->productService->removeProductDefaultImage($p_id) ? 'success' : 'error';
$this->productService->updateProductStatus($p_id, 'Draft');
exit;
break;
case 'upload_resource_preview':
// images on the image tab
$resource_type = \Input::get('resource_type');
$this->productAddService->setProductPreviewType($p_id);
$this->productAddService->setAllowedUploadFormats('preview');
$this->productAddService->setMaxUploadSize('preview');
$resource_count = ProductResource::whereRaw('product_id = ? AND resource_type = ? ', array($p_id, $this->productAddService->product_media_type))->count();
if ($resource_count < \Config::get('webshoppack::preview_max')) {
$file_info = array();
$file = \Input::file('uploadfile');
$upload_file_name = $file->getClientOriginalName();
$upload_status = $this->productAddService->uploadMediaFile('uploadfile', $this->productAddService->product_media_type, $file_info);
if ($upload_status['status'] == 'success') {
$resource_arr = array('product_id' => $p_id, 'resource_type' => $resource_type, 'filename' => $file_info['filename_no_ext'], 'ext' => $file_info['ext'], 'title' => $file_info['title'], 'width' => $file_info['width'], 'height' => $file_info['height'], 't_width' => $file_info['t_width'], 't_height' => $file_info['t_height'], 'l_width' => $file_info['l_width'], 'l_height' => $file_info['l_height'], 'server_url' => $file_info['server_url'], 'is_downloadable' => $file_info['is_downloadable']);
$resource_id = $this->productService->insertResource($resource_arr);
$image_dim = CUtil::DISP_IMAGE(74, 74, $file_info['t_width'], $file_info['t_height'], true);
$this->productService->updateProductStatus($p_id, 'Draft');
echo json_encode(array('status' => 'success', 'resource_type' => ucwords($resource_type), 'server_url' => $file_info['server_url'], 'filename' => $file_info['file_thumb'], 't_width' => $image_dim['width'], 't_height' => $image_dim['height'], 'title' => $file_info['title'], 'resource_id' => $resource_id));
} else {
echo json_encode(array('status' => 'error', 'error_message' => $upload_status['error_message'], 'filename' => $upload_file_name));
}
} else {
echo json_encode(array('status' => 'error', 'error_message' => trans('webshoppack::products_max_file'), 'filename' => ''));
}
exit;
break;
case 'save_resource_title':
$row_id = \Input::get('row_id');
$resource_title = \Input::get('resource_title');
echo $this->productService->updateProductResourceImageTitle($row_id, $resource_title) ? 'success' : 'error';
$this->productService->updateProductStatus($p_id, 'Draft');
exit;
break;
case 'delete_resource':
$row_id = \Input::get('row_id');
//.........这里部分代码省略.........