Jump to content


can I use the imagecrud image_path dynamically with 'category'

imagecrud upload category

  • Please log in to reply
10 replies to this topic

#1 slickdaze

slickdaze

    Newbie

  • Members
  • Pip
  • 4 posts

Posted 21 May 2013 - 04:29 PM

hi there, I hope it's ok to ask a question about imageCRUD here..   hopefully this is quick and easy! I am trying to use imageCRUD as part of a backend for a prototype property site, and as such, I'm using the 'set relation' setting as the property id. I'd also like to be able to dynamically set the upload path depending on the property id in the url. However, I can't get it to work when I construct the variable form the url (images do not upload). When I force the upload path by simply manually setting a string, it works fine.  (although there is a red error message appearing on both, but it disappears so fast I can't see what it says) Here's some test code.



function edit($id) { 
    $this->load->model('Model_addproperty'); 
    $details = $this->Model_addproperty->get_org_user_from_property($id); 
    $path_to_images = "media/" . $details->organisation_id . "/" . $details->user_id . "/" . $id . "/img"; 
    var_dump($path_to_images); 

    $path_to_images2 = 'media/20011/3002315/294967295/img'; 
    var_dump($path_to_images2); //these two var_dumps are always identical.
    
    $image_crud = new image_CRUD(); 
    $image_crud->set_url_field('url'); 
    $image_crud->set_table('images') 
      ->set_relation_field('property_id') 
      ->set_ordering_field('priority') 
      ->set_image_path($path_to_images2); // change between 1 and 2 to test. 

    $output = $image_crud->render(); 
    $this->load->view('view_imageedit.php',$output); 
}

Any pointers gratefully received .. I think is this is something easy. Am I perhaps interfering with what the library is doing with the uri segments? Chrz.



#2 davidoster

davidoster

    Grocery CRUD Ninja

  • Advanced Member
  • PipPipPip
  • 1,068 posts
  • LocationAthens, Greece

Posted 28 May 2013 - 07:37 AM

Hello and welcome to the forums.

Sorry for the late reply.

 

Are you certain that this line $details = $this->Model_addproperty->get_org_user_from_property($id); produces ALWAYS the desired result?

 

Can you post the code of this function?


____________________________________________________________

 

rtfm_small.jpg---!!!Please read these guidelines before asking to the forums!!!---

____________________________________________________________

 

David Oster aka George Pasparakis,
http://odphotography.com
http://eletter.gr


#3 slickdaze

slickdaze

    Newbie

  • Members
  • Pip
  • 4 posts

Posted 03 June 2013 - 01:20 PM

Hi, thanks for reply. Yes, the function is very simple, as follows:



function get_org_user_from_property($property_id){ 
   $this->db->select('user_id, organisation_id'); 
   $query = $this->db->get_where('propertys', array('id' => $property_id)); 
   return $query->row(); 
}

When I force the image path (use $path_to_images2) everything goes well, but when I try to use the dynamic incoming url (change to $path_to_images) it goes wrong. The database gets updated, and the browser tries to load the image, but it can't find it because it didn't upload. I've attached a screenshot. You can also see the var_dumps are the same. I really think this is something silly, but I can't figure it out!

 

Many thanks.

Attached Thumbnails

  • Screen Shot 2013-06-03 at 14.14.17.png


#4 davidoster

davidoster

    Grocery CRUD Ninja

  • Advanced Member
  • PipPipPip
  • 1,068 posts
  • LocationAthens, Greece

Posted 03 June 2013 - 09:12 PM

Well the only thing I can think of right now is that the two string are not identical and the only way this to happen is either/or :

1. some of the zeros are capital O's

2. there are some spaces or some other unprintable chars

 

Try to make an if == to see if the are really identical.

 

Also try to rename the function from edit to something else.


Edited by davidoster, 03 June 2013 - 09:14 PM.

____________________________________________________________

 

rtfm_small.jpg---!!!Please read these guidelines before asking to the forums!!!---

____________________________________________________________

 

David Oster aka George Pasparakis,
http://odphotography.com
http://eletter.gr


#5 slickdaze

slickdaze

    Newbie

  • Members
  • Pip
  • 4 posts

Posted 04 June 2013 - 06:11 AM

Yes, I was hoping it was something obvious but I've tried everything like that. I've now added a third string comparison, and also a check to see whether they're all identical, and you can see the result in the attachment pic. You can also see where some pictures work fine and others don't ... this is where I'm changing the code - only the fixed string works, it never works when working with an incoming segment argument. Current code is:




function edit($id) { 
$this->load->model('Model_addproperty'); 
$details = $this->Model_addproperty->get_org_user_from_property($id); 
$path_to_images = "media/" . $details->organisation_id . "/" . $details->user_id . "/" . $id . "/img"; var_dump($path_to_images); 
$path_to_images2 = 'media/20011/3002315/' . (string)$id .'/img';  
$path_to_images3 = 'media/20011/3002315/294967296/img'; 

if($path_to_images === $path_to_images2 
&& $path_to_images === $path_to_images3) 
{echo "they all seem to match";} 

$image_crud = new image_CRUD(); 
$image_crud->set_url_field('url'); 
$image_crud->set_table('images') 
->set_relation_field('property_id') 
->set_ordering_field('priority') 
->set_image_path($path_to_images3); // change between 1,2,3 to test. 

$output = $image_crud->render(); 
$this->load->view('view_imageedit.php',$output); 
}

Thanks.

 

Screen Shot 2013-06-04 at 07.04.41.png



#6 davidoster

davidoster

    Grocery CRUD Ninja

  • Advanced Member
  • PipPipPip
  • 1,068 posts
  • LocationAthens, Greece

Posted 04 June 2013 - 09:40 AM

Shame on me that I didn't think of it before!!!

The set_path is a global path for all the photos. It's not on a per photo basis.

It holds always the last change you make!

In order to do what you're trying to, you must change the way the model of Image CRUD works!!!


____________________________________________________________

 

rtfm_small.jpg---!!!Please read these guidelines before asking to the forums!!!---

____________________________________________________________

 

David Oster aka George Pasparakis,
http://odphotography.com
http://eletter.gr


#7 slickdaze

slickdaze

    Newbie

  • Members
  • Pip
  • 4 posts

Posted 04 June 2013 - 02:28 PM

I'm not so sure, I'm not trying to upload different images to different places from the same class instantiation.  When I test this code, I always keep the incoming $id argument the same, so $path_to_images 1, 2, & 3 are always identical.

 

Is this still not possible? Thanks for your help by the way!



#8 davidoster

davidoster

    Grocery CRUD Ninja

  • Advanced Member
  • PipPipPip
  • 1,068 posts
  • LocationAthens, Greece

Posted 04 June 2013 - 10:10 PM

The path is not the same between different images. Is it?

Forget about it! It is! What is changing is the user id.

I have no idea then. Why don't you debug?


Edited by davidoster, 04 June 2013 - 10:13 PM.

____________________________________________________________

 

rtfm_small.jpg---!!!Please read these guidelines before asking to the forums!!!---

____________________________________________________________

 

David Oster aka George Pasparakis,
http://odphotography.com
http://eletter.gr


#9 Sam Stha

Sam Stha

    Newbie

  • Members
  • Pip
  • 4 posts

Posted 18 September 2014 - 06:30 PM

do anyone solve this problem??



#10 hasan37

hasan37

    Newbie

  • Members
  • Pip
  • 2 posts

Posted 15 April 2015 - 07:52 AM

Has anyone found a solution for this?



#11 hasan37

hasan37

    Newbie

  • Members
  • Pip
  • 2 posts

Posted 15 April 2015 - 07:54 AM

This is what i have been trying.

function example1()
	{	
		$album = $this->input->get('album');
		
		$set_album = "assets/uploads/".$album;
		
		$image_crud = new image_CRUD();
		
		$image_crud->set_primary_key_field('id');
		$image_crud->set_url_field('url');
		$image_crud->set_table('example_1')
			->set_image_path($set_album);
			
		$output = $image_crud->render();
		
		$this->_example_output($output);
	}






Also tagged with one or more of these keywords: imagecrud, upload, category

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users