Welcome, Guest
Username: Password: Remember me

TOPIC: [FIXED] Path generated by JDOM to display images

[FIXED] Path generated by JDOM to display images 23 Jul 2012 13:12 #2846

  • Ferm
  • Ferm's Avatar
  • Offline
  • Junior Member
  • Posts: 39
  • Thank you received: 6
  • Karma: 2
I am adding a component to a site that is using Community Builder. The possibilities for displaying lists and profiles in CB are quite limited so I am building a component with J-Cook to display a couple of customised lists depending on the type of user logged on.

After installing the component generated with J-Cook, I just changed the table name to #__comprofiler (which is where CB stores member information) and it works brilliantly.

The only tricky bit is to display images. Community builder is storing images by saving the file name in a field called avatar and the actual image file is stored in images/comprofiler.

To display an image in a form, I use the following code:

echo JDom::_('html.fly.file.default', array(
'dataKey' => 'avatar',
'dataObject' => $this->comprofilerform,
'width' => 'auto',
'height' => 'auto',
'attrs' => array('format:png'),
'indirect' => true,
'root' => JPATH_SITE.'/images/comprofiler/'
));

This is the J-Cook generated code with the 'root' parameter changed. This generates the correct html code, bit for some reason, the image does not display on my site. It works on a freshly installed empty Joomla site but not on the one I am working on. I have tried to play around with cache settings etc, but I haven't found anything that works.

To work around the problem, I tried changing the 'indirect' parameter to false. A direct link to the image works, but it seems that the Jdom function doesn't include the path to the image when the indirect parameter is set to false.

So the above code with indirect set to true generates this html with the correct path:

<div class="img-zone" style="width:264px;height:348px; overflow:hidden;display:inline-block;">
<img width="264px" height="348px" style="" src="/gpc2/index.php?option=com_mbrs&task=file&attrs=format:png&path=/var/www/gpc2/images/comprofiler/65_4ff9f48d13755.jpg">
</div>

and with the indirect set to false, this

<div class="img-zone" style="width:264px;height:348px; overflow:hidden;display:inline-block;">
<img width="264px" height="348px" style="" src="/gpc2/65_4ff9f48d13755.jpg">
</div>

As you can see, the path is different. With the indirect set to false, the images/comprofiler bit is missing and it will look in gpc2 which is the root directory for the application.

So I have two questions:

1. Has anyone else had site-specific problems displaying images with Jdom and how did you fix it?
2. Is Jdom really meant to generate that path when indirect is set to false? I can't see how that could work.

Grateful for any help!
The administrator has disabled public write access.

Re: Path generated by JDOM to display images 23 Jul 2012 18:09 #2848

  • admin
  • admin's Avatar
  • Online
  • Administrator
  • Chef
  • Posts: 3711
  • Thank you received: 985
  • Karma: 140
Should be solved now.

The only one changed file is :
dom/html/fly/file.php
Coding is now a piece of cake
The administrator has disabled public write access.
The following user(s) said Thank You: Ferm

Re: Path generated by JDOM to display images 24 Jul 2012 10:18 #2854

  • Ferm
  • Ferm's Avatar
  • Offline
  • Junior Member
  • Posts: 39
  • Thank you received: 6
  • Karma: 2
Yep, it works now. Thanks for the ultra quick response!

Erik
The administrator has disabled public write access.
Time to create page: 0.086 seconds

Get Started