[SOLVED] Display db image from related model

Is it possible to display a image stored in a db from a related model?

It’s simple enough when viewing within the same model following this link

and using this


<? echo CHtml::link(my_link_name,array('displaySavedImage','id'=>$model->primaryKey)); ?>

but now I want to display an image from a related model. Any ideas?




<? echo CHtml::link(my_link_name,array('displayRelatedImage','id'=>$model->related->primaryKey)); ?>



I have tried this even with specifying the controller/displayImage and get nothing. Have you got this working?

provide error message you get (or results), model(s) code, etc. it is realy hard to think why something is not working without seeing it…

Ok this is what got things working. I changed the relation to HAS_ONE although if you implode the array for HAS_MANY it should work the same although didn’t test.


$dbImage = $this->createUrl('model/displaySavedImage',array('id'=>$model->related->primaryKey)); 

echo CHtml::image($dbImage,'image');