1
0
Fork 0

Add dimensions and size of an image for display.

This commit is contained in:
Andrew Tomaka 2011-11-08 18:20:43 -05:00
parent 6c2dab5c50
commit 807f73ffbd
5 changed files with 26 additions and 6 deletions

View file

@ -23,7 +23,11 @@ class Upload extends CI_Controller {
$message = array('type' => 'error', 'status' => $this->upload->display_errors()); $message = array('type' => 'error', 'status' => $this->upload->display_errors());
} else { } else {
$upload = $this->upload->data(); $upload = $this->upload->data();
$hash = md5_file($upload['full_path']); $hash = md5_file($upload['full_path']);
$width = $upload['image_width'];
$height = $upload['image_height'];
$size = $upload['file_size'];
$this->load->model('fileupload'); $this->load->model('fileupload');
$duplicate = $this->fileupload->check_duplicate($hash); $duplicate = $this->fileupload->check_duplicate($hash);
@ -33,7 +37,7 @@ class Upload extends CI_Controller {
$message = array('type'=>'error', 'status'=>'file already exists:' . $duplicate); $message = array('type'=>'error', 'status'=>'file already exists:' . $duplicate);
} else { } 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']); rename($upload['full_path'], $upload['file_path'] . $file_name . $upload['file_ext']);

View file

@ -44,6 +44,10 @@ class View extends CI_Controller {
$this->data['original'] = $upload->original_name; $this->data['original'] = $upload->original_name;
$this->data['views'] = $display_views; $this->data['views'] = $display_views;
$this->data['created'] = $upload->created; $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); $this->template->load('template', 'view', $this->data);
} }

View file

@ -5,10 +5,13 @@ class Fileupload extends CI_Model {
parent::__construct(); parent::__construct();
} }
function add_upload($extension, $original_name, $hash) { function add_upload($extension, $original_name, $width, $height, $size, $hash) {
$data = array( $data = array(
'extension' => $extension, 'extension' => $extension,
'original_name' => $original_name, 'original_name' => $original_name,
'width' => $width,
'height' => $height,
'size' => $size,
'hash' => $hash, 'hash' => $hash,
); );
@ -22,7 +25,7 @@ class Fileupload extends CI_Model {
} }
function get_upload($id) { 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(); $query = $this->db->get();
$result = $query->result(); $result = $query->result();

View file

@ -30,7 +30,6 @@
</div> </div>
<div id="message"> <div id="message">
Uploaded on: <?php echo $created; ?><br/> <span class="label">Uploaded on:<br/>Original name:<br/>Views:<br/>Dimensions:<br/>Size:</span>
Original name: <?php echo $original; ?><br/> <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>
Views: <?php echo $views; ?><br/>
</div> </div>

View file

@ -262,6 +262,16 @@ h1{
font-weight: bold; font-weight: bold;
} }
.label {
display: inline-block;
font-weight: bold;
text-align: right;
}
.info {
display: inline-block;
}
/*------------------------- /*-------------------------