Jump to content


jrowe

Member Since 05 May 2012
Offline Last Active Jun 25 2013 04:25 PM
-----

Topics I've Started

Image Crud - uploading too many kills session variable

17 May 2013 - 12:51 PM

I have been using grocery crud + image crud together with tankauth to create a album storage area for images. It seemed to be working great until my gf tried to upload a whole folder worth of images ( like 100+ ). what happens is she logs in, creates an album (with grocery crud) then clicks a custom action to add images ( image crud with category - the album id ). It will upload about 30ish images then it will stop and send her to the log in screen..I suppose this is because the session variable is being destroyed. Is there any way that during the upload loop to refresh the session variables to prevent this ?

 

Is there a set size or limit of images that image crud can upload?


Image Crud - Rotate image from Thumbnail view

14 May 2013 - 01:15 PM

A simple implementation I did so that I can rotate images after they upload. It rotates both the thumbnail and full sized image.

 

In my controller that renders the image crud

function rotateimage($pkey){
$this->load->library('image_moo');

$basepath='assets/uploads/';
$images = $this->db->get_where('pictures', array('id'=>$pkey))->result();
 

    if(!empty($images))
    {
    
       foreach($images as $row){
             $filestring = $basepath.$row->url;
             $filestringthumb=$basepath.'thumb__'.$row->url;
             $this->image_moo->set_jpeg_quality('60');
           $this->image_moo->load($filestring)->rotate('90')->save($filestring,true);
               $this->image_moo->load($filestringthumb)->rotate('90')->save($filestringthumb,true);
                $this->image_moo->set_jpeg_quality('60');

        
        }

    }
    else{
    //primary key not found

 }
 
} 

Then , under assets/image_crud/views/list.php I added this javascript:

<script type='text/javascript'>
		$(function(){
			$('.rotate-anchor').click(function(){
				
					$.ajax({
						url:$(this).attr('href'),
						beforeSend: function()
						{
			
						//can show "wait" screen here
						},
						success: function(){
							loadPhotoGallery();
					}
					});
				
				return false;
			});
				
		});
	</script>

Also, under assets/image_crud/views/list.php I also added this link to the thumbnails (under the foreach of ul showing the images:

<a href="<?php echo 'http://localhost/controller/rotateimage/'. $photo->$primary_key; ?>" class="rotate-anchor"> Rotate </a>

Finally.. I found out that after the rotating the thumbnails were not refreshing with the new rotated version so to force the refreshing of the thumbnail I added a random value to prevent it from being cached:

I switched this:
<img src='<?php echo $photo->thumbnail_url?>' width='90' height='60' class='basic-image' />


to this: (to get it to refresh after being rotated)


<img src='<?php echo $photo->thumbnail_url.'?timestamp='.rand(1,3000); ?>' width='90' height='60' class='basic-image' />

Also had to change this:

<a href='<?php echo $photo->image_url;?>' <?php if (isset($photo->title)) {echo 'title="'.str_replace('"',"&quot;",$photo->title).'" ';}?>target='_blank' class="color-box" rel="color-box" tabindex="-1"><img src='<?php echo $photo->thumbnail_url.'?timestamp='.rand(1,3000); ?>' width='90' height='60' class='basic-image' /></a>

To this:

<a href='<?php echo $photo->image_url.'?timestamp='.rand(1,3000);?>' <?php if (isset($photo->title)) {echo 'title="'.str_replace('"',"&quot;",$photo->title).'" ';}?>target='_blank' class="color-box" rel="color-box" tabindex="-1"><img src='<?php echo $photo->thumbnail_url.'?timestamp='.rand(1,3000); ?>' width='90' height='60' class='basic-image' /></a> 

This will prevent caching of the normal size image incase they rotate it and they click the thumbnail to show the full size image

 

This will rotate both the thumbnail and the normal sized image by 90 degrees... 

 

One problem I am having is that the thumbnails quality degrades if you rotate it alot, the normal sized image seems to not..


Image crud - batch delete from thumbnail view

12 May 2013 - 04:23 PM

Has any one created the functionality of having check boxes and a button in the thumbnail view to "batch" delete uploaded images? Would be nice if you wanted to delete many pictures but not one at a time. I was also going to take a stab at this but wanted to ask the community first..


Image crud - rotate image after uploading

12 May 2013 - 04:20 PM

Was wondering if any one has implemented a "rotate image" functionality so that you can rotate images that are uploaded that need to be rotated and resaved as such (thumbnail and regular size image)? preferably this could be done at the thumbnail view. I was planning on taking a stab at it but thought maybe someone else already tackled this problem.


add action with onclick attritibute

30 April 2013 - 06:54 PM

I am trying to create a add action that will have a on click event that will use javascript to force a download without redirecting the entire page. Without using jquery hacks, is it possible to add this while building the rendering of the crud?