I have this very simple problem re file paths, and yet I have been trying to solve the problem to no avail. Your help would be much appreciated. I'开发者_JS百科m new to Joomla and here is my problem.
I would like to show an image located in the images folder of my component.
Example Path:
/joomlabasedir/components/com_mycomponent/images/image1.png
How can I correctly set the path to this image, from inside a view of my component.
I've tried the following in my code:
<img src="./images/images1.png">
But when the page gets loaded, the src gets prefixed with the SEF formatted link of the page that is currently being displayed.
Example. While viewing a 'View' called event, instead of the image path pointing to : localhost/joomla/components/com_mycomponent/images/image1.png,
it points to the SEF formatted link as show below,
localhost/joomla/index.php/component-alias/event/images/image1.png
which is obviously the wrong path and results to a 404 error.
I have also tried using JPATH_ROOT, JPATH_COMPONENT, and also failed since these paths are actually giving the filesystem path of the file, which is considered as local resource thus can't be loaded.
I hope someone can help me on this seemingly trivial problem that I failed solve.
Thank you!
<img src="<?php echo JURI::root();?>components/com_mycomponent/images/images1.png">
If you are using JCE editor (i think it's the most effective), your default directory is /images/stories.
So...you must create a directory inside the stories directory, and when you link it, just write "directoryname/image1.png" in source, or just click the image button, and your directory will show with the image inside ! Click the image, and isert!
If you don't want to copy your image there, you can link like http://yoursite.com/components/com_componentname/images/image1.png like a usual URL.
精彩评论