Laliwala IT Services

Laliwala IT Services
Website Development

Monday, February 21, 2011

How to add image to a portlet ?



mukul karjule : Hi,
I have developed my own portlet using plugin but I am not able to add image to that portlet.
I am using Liferay 6.0.0 with tomcat
How can I do that ?
please help..
thanks in advance...
Amos Fong : Hi Mukul,
Can you be more specific? What do you mean add an image to the portlet? What kind of image are you adding and for what?
Amos
mukul karjule : Hi,
I want to add .jpg image. that means I want to show that image as a part of portlet
Sandeep Nair : Hi,
You can create a folder named images inside your docroot folder of the portlet and can access any image placed in that in the jsp.
For example if you have image abc.jpg inside images folder, you can access the same using

the following.
<img src="/images/abc.jpg"/>
Regards,

Sandeep
mukul karjule : Its not working .. emoticon
Babu Janarthanan : which environment are you using?
double check your path.
mukul karjule : I am using win XP and Liferay 6.0.0 with Tomcat and MySQL as database.
I checked path twice but still it is not working ... emoticon
Babu Janarthanan : are you getting any errors, can you post your code and screen shot of your browser?
Sandeep Nair : Can you use firebug to check the path. Basically if you see your portlet, it has an icon.png that is inside docroot folder. Have a look at liferay-portlet.xml of your portlet. The icon.png is accessed as /icon.png.
Similarly if you have a folder named images inside docroot, then you should be able to access the images inside it by /images/xyz.jpg
You can check the same using firebug. Like use firebug to check the path of icon.png of the portlet, and then modify it with your image path.
Regards,
Sandeep
mukul karjule : Hi,

Babu Janarthanan : do you have support.jpg or support.JPG in your image folder, try to check the extn and check it out by replacing .jpg to .JPG.
trouble shoot using mozilla firebug.
mukul karjule : I tried but still not working
Mazhar Anwar : Hi Mukul,
You have to add context path in your image path.
try as follows,
Suppose your image in docroot/images/abc.jpg, so in jsp, access the image as follows,
Hope this will Help..
Regards,
MohdFaizul Sulaiman : That will only works if the image is already available when you deploy the portlet.
I had the same problem when I dynamically upload an image into the directory tomcat/webapps/myportlet/images.
Since the context goes to tomcat/temp/0-myportlet, the file will not visible unless I save it in temp/0-myportlet/images. But if I save it in temp directory, the temp will be cleared when I restart the tomcat.
So, I have to put it in both location. In the temp/0-myportlet, to make it visible and in the webapps/myportlet to make it available after restarting tomcat.
I'm still hoping that someone would help me with a better solution.
Pushpinder Singh :
Hi mate, may be you can load image in some image gallery and copy paste path from image gallery into your <img> tag.

2 comments:

  1. I аm really inѕpireԁ ωith уour wrіting
    talents as neatlу as wіth the ѕtructure to your weblog.
    Iѕ this a paid topic or did уou moԁify іt
    уourself? Еithег waу kееp up the nice high
    quality writing, it's uncommon to see a great weblog like this one today..

    Here is my web-site; pure raspberry ketone

    ReplyDelete
  2. Can you please provide some link or material which direct me to understand liferay' socument & media.

    I have similar problem for image.....

    ReplyDelete