In the middle of ironing out some wonky code, I came across a lovely issue with IE (who hasn’t?) stemming from its habit of adjusting the mime type of submitted jpegs as “pjpegs” or progressive jpegs. The issue is well documented, but I was continuing to have issues with formatting correct image types. The situation seemed hopeless.
What I was originally convinced was an input problem actually ended up being an output problem, namely how the images were being rendered by my image view controller. Below illustrates a perfect example of a quick, hacky solution that ended turning around and stealing 5 hours of productivity down the road.
Take a look:
$image_types = array('image/jpeg', 'image/gif', 'image/png');
//selecing only images
$pictures = $this->Job->Upload->find('all', array('conditions' =>array('Upload.job_id' => $id, 'upload_content_type' => $image_types)));
//selecting everything else (pdf, document, etc...)
$documents = $this->Job->Upload->find('all', array('conditions' =>array('Upload.job_id' => $id, "NOT" => array('upload_content_type ' => $image_types))));
//send results to the view
$this->set(compact('pictures', 'documents'));
Harmless enough, right?
Do it right, or don’t do it at all. Shame on me.
Don’t make the same mistake.
