Planned maintenance is scheduled for the week of June 15th - the exact date and time will be announced soon.
See More Details
Ask Questions and Find Answers
Important:
Ask is now read-only. You can review any existing questions and answers, but not add anything new.
But - don't panic! While ask is no more, we've replaced it with discuss - the new Liferay Discussion Forum! Read more here here or just visit the site here:
discuss.liferay.com
How t0 get Image from resource folder in Module Project ???
hello,
I am trying to get image from resource folder but its not getting with same path i am able to fetch image but in render method i can't , so anybody have idea that how we can get image from resource folder of module project in our render method. and the code is as below for getting image
" ClassLoader classLoader = getClass().getClassLoader();
File file = new File("IMG/child2.jpeg"); "
thanx in advance
I am trying to get image from resource folder but its not getting with same path i am able to fetch image but in render method i can't , so anybody have idea that how we can get image from resource folder of module project in our render method. and the code is as below for getting image
" ClassLoader classLoader = getClass().getClassLoader();
File file = new File("IMG/child2.jpeg"); "
thanx in advance
Instead of doing the 'new File() thing, you just load the stream and use it:
InputStream is = classLoader.getResourceAsStream("/META-INF/resources/IMG/child2.jpeg");
But getting your own image kind of means the code is doing way more than it needs to (or is a sign that you're doing things wrong in general). Using an <img /> tag back to your own context would serve up the image w/o going through the stream handler.
InputStream is = classLoader.getResourceAsStream("/META-INF/resources/IMG/child2.jpeg");
But getting your own image kind of means the code is doing way more than it needs to (or is a sign that you're doing things wrong in general). Using an <img /> tag back to your own context would serve up the image w/o going through the stream handler.
Community
Company
Feedback