Correct path to images in the File Manager

Permalink
Hi all. I've installed a Slider and have a question about linking to images in the file manager. Entering the whole filename as below works fine. However, the site is on my hard drive just now while I build it, what happens when the site goes onto the hosting server, the path will then be different will it not?
<img src="http://localhost:8888/sitename/files/7113/4859/9461/2a.jpg"/>

Only using this part "files/7113/4859/9461/2a.jpg" worked for the first image in the slideshow but not the rest which showed as missing images.

Very grateful for any help.

 
adajad replied on at Permalink Reply
adajad
If you read and follow this blog post by Jordan I think you will be able to build your own block with your slider and also hook into the File Manager.

http://c5blog.jordanlev.com/blog/2011/12/build-a-slideshow-block/...
DanK replied on at Permalink Reply
Sorry Adajad that's not what I meant. I'm looking to know how I link to the images I have uploaded into Sets in the File Manager.

By clicking on the images I know where they are but, as on the example I posted above, the path shows to the location on my local drive. What happens when I move the site to a live server? I assume that the path will be broken so I need to know how to write the link in order that when I move it to a web server the link will not break.

Thanks for replying anyway.
adajad replied on at Permalink Reply
adajad
If you are are using the slider as part of your theme (hardcoded) you should put yor images in your themes directory and call them with $this->getThemePath. If you look in the how-to section (under documents top right) you should try to locate a how-to by 12345j and Jordanlev describing how you make a theme from start to finish. In there they describe how yo call images and other elements in a theme.

Edit: stupid auto correct on my phone
DanK replied on at Permalink Reply
Thanks again adajad. The images I'm referencing have been uploaded into Sets in the File Manager. I select the image in the File Set, click Properties and find the path from there. They are not in the theme folder. I just need to know what path to use so that when the site goes from my local disk to the live server the image links are not broken (the example shown in my first question shows the file coming from my local disk).
adajad replied on at Permalink Reply
adajad
I am afraid you won't get any better answer. If the slider is a part of the theme and the images are hardcoded in, you should have the required images in you themes directory. If you take the high way and include them from a fileset or the file manager you always risk having the fileset or file renamed or edited by someone, which will then render your slider (hardcoded in your theme) useless.

Please see this link on how to include images in a theme http://www.concrete5.org/documentation/how-tos/designers/making-a-t...

I am currently on my phone and will not be back in the office for another 11 hours. If you are still having problems with your slider and the images by then, post back here with your theme and slider code and I can take a loo. If you don't want to put your code up for public display you can send it in a private message to me.
DanK replied on at Permalink Reply
Thanks again for your time. I'm not using a pre-built theme, it's a website I've built from scratch. I suppose a better way to ask the question would be this:

If I want to reference the source of an image that is in a Set in the File Manager what is the correct path to it? Currently, under Properties it shows the absolute URL:
http://localhost:8888/name-of-site/files/7113/4859/9461/2a.jpg...

When I upload the site to a web server I assume that this absolute link will be broken. I need to know if it is possible to use a relative URL instead (tried but it didn't work). I have hundreds of images to add and it would be a nightmare to have to relink them all when the site moves to the live server.
adajad replied on at Permalink Reply
adajad
You could use

<img src="<?php echo DIR_REL ?>/files/7113/4859/9461/2a.jpg>


DIR_REL will output your base url (http://www.your_domain.com)

I once again strongly encourage you _not_ to hard code in your image sources from the file manager but instead create a block from the slider and use that instead. If you don't know how to do it (which is really understandable) then maybe there already is a slider available in the marketplace that meets your needs.

Do you mind sharing a link to the slider?
DanK replied on at Permalink Reply
I'm very aware that I'm taking up a lot of your time. Unfortunately I can't change the slider as I'm using SlideDeck and the clients wants that exact functionality. I tried using the code you sent with no luck.

I must be doing something hugely wrong here but I can't be the first person who has a jQuery slider that needs images put in a folder in the File Manager. Is it possible to put these images directly into a folder in my theme folder and if so how would I access them?

Thanks again for all of your help.
adajad replied on at Permalink Best Answer Reply
adajad
:)

If you don't ask, you will never know. I am happy to answer questions as that helps me keep sharp and find solutions I didn't even know was possible.

To answer your question you could have your images in your theme folder.

Lets assume you have the folder structure below (with any number of subfolders);

webroot
- themes
-- your_theme
--- images
---- subfolder

You can then call your images with:
<img src="<?php echo $this->getThemePath(); ?>/images/subfolder/image.jpg" width="400px" height="150px" alt="" />


Just to be curious, have you looked at (and presented) the sliders available in the marketplace? You will get a lot for the money buying one (not to mention saving time for you and your client and support from the developer). On the right hand side in the marketplace you can filter on 'image sliders' and make sure you also check '5.5 Ready'. I won't tell you why I consider this a better option, since I have before. It might be one of the already packaged sliders have the functionality of SlideDeck your client is after.
DanK replied on at Permalink Reply
And STILL it doesn't work!! Ahhh!!!

I'm going back to the SlideDeck guys as this is just driving me nuts. The code you gave me is as straightforward as possible and if that doesn't work there must be something else wrong.

I've used sliders from the c5 Marketplace and they work great, installed and working in two minutes. This pile of cr@p cost me $50 and I've spent about $500 worth of time trying to get the damn thing working.

There's got to be an easier way to earn a living... Thanks again though for all your help, really appreciated.
Spletnapot replied on at Permalink Reply
Spletnapot
if you ask me <img src ... <?php echo DIR_REL ?> will look in themes dir. This can be used for images in template. Echo dir_rel is kinda pointless for inside blocks-slider.

http://localhost:8888/name-of-site/files/7113/4859/9461/2a.jpg...
http://domain.com/files/7113/4859/9461/2a.jpg...

i would point to jpg like: /files/7113/4859/9461/2a.jpg
on actual server/hosting the base url will be / .. domain.com/files......

try with / infront files ... /files/......
all links as images or ahref should be withouth domain as base url takes care of that.

Hope this helps ya