Add dimensions and size of an image for display.
This commit is contained in:
parent
6c2dab5c50
commit
807f73ffbd
5 changed files with 26 additions and 6 deletions
|
@ -23,7 +23,11 @@ class Upload extends CI_Controller {
|
|||
$message = array('type' => 'error', 'status' => $this->upload->display_errors());
|
||||
} else {
|
||||
$upload = $this->upload->data();
|
||||
|
||||
$hash = md5_file($upload['full_path']);
|
||||
$width = $upload['image_width'];
|
||||
$height = $upload['image_height'];
|
||||
$size = $upload['file_size'];
|
||||
|
||||
$this->load->model('fileupload');
|
||||
$duplicate = $this->fileupload->check_duplicate($hash);
|
||||
|
@ -33,7 +37,7 @@ class Upload extends CI_Controller {
|
|||
|
||||
$message = array('type'=>'error', 'status'=>'file already exists:' . $duplicate);
|
||||
} else {
|
||||
$file_name = $this->fileupload->add_upload($upload['file_ext'], $upload['client_name'],$hash);
|
||||
$file_name = $this->fileupload->add_upload($upload['file_ext'], $upload['client_name'],$width,$height,$size,$hash);
|
||||
|
||||
rename($upload['full_path'], $upload['file_path'] . $file_name . $upload['file_ext']);
|
||||
|
||||
|
|
|
@ -44,6 +44,10 @@ class View extends CI_Controller {
|
|||
$this->data['original'] = $upload->original_name;
|
||||
$this->data['views'] = $display_views;
|
||||
$this->data['created'] = $upload->created;
|
||||
$this->data['height'] = $upload->height;
|
||||
$this->data['width'] = $upload->height;
|
||||
$this->data['size'] = $upload->size;
|
||||
|
||||
|
||||
$this->template->load('template', 'view', $this->data);
|
||||
}
|
||||
|
|
|
@ -5,10 +5,13 @@ class Fileupload extends CI_Model {
|
|||
parent::__construct();
|
||||
}
|
||||
|
||||
function add_upload($extension, $original_name, $hash) {
|
||||
function add_upload($extension, $original_name, $width, $height, $size, $hash) {
|
||||
$data = array(
|
||||
'extension' => $extension,
|
||||
'original_name' => $original_name,
|
||||
'width' => $width,
|
||||
'height' => $height,
|
||||
'size' => $size,
|
||||
'hash' => $hash,
|
||||
);
|
||||
|
||||
|
@ -22,7 +25,7 @@ class Fileupload extends CI_Model {
|
|||
}
|
||||
|
||||
function get_upload($id) {
|
||||
$this->db->select('extension, original_name, views, created')->from('uploads')->where('id',$id);
|
||||
$this->db->select('extension, original_name, width, height, size, views, created')->from('uploads')->where('id',$id);
|
||||
$query = $this->db->get();
|
||||
|
||||
$result = $query->result();
|
||||
|
|
|
@ -30,7 +30,6 @@
|
|||
</div>
|
||||
|
||||
<div id="message">
|
||||
Uploaded on: <?php echo $created; ?><br/>
|
||||
Original name: <?php echo $original; ?><br/>
|
||||
Views: <?php echo $views; ?><br/>
|
||||
<span class="label">Uploaded on:<br/>Original name:<br/>Views:<br/>Dimensions:<br/>Size:</span>
|
||||
<span class="info"><?php echo $created; ?><br/><?php echo $original; ?><br/><?php echo $views; ?>x<?php echo $width; ?><br/><?php echo $height; ?><br/><?php echo $size; ?>kb</span>
|
||||
</div>
|
|
@ -262,6 +262,16 @@ h1{
|
|||
font-weight: bold;
|
||||
}
|
||||
|
||||
.label {
|
||||
display: inline-block;
|
||||
font-weight: bold;
|
||||
text-align: right;
|
||||
}
|
||||
|
||||
.info {
|
||||
display: inline-block;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*-------------------------
|
||||
|
|
Loading…
Reference in a new issue