Content block images not displaying properly
Permalink
Hello fellow forumers,
Been trying to figure this out on my own for a few days now, so figured I'd better ask the pros.
I've created a stack with a content block that includes html for displaying images. The only way I can seem to get the images to display on my site is to add them via the content block.
When I reference the images via html code, they do not show up. Furthermore, if I place the exact same html code directly into the .php file without using a content block, the images show up then.
Below are the two pieces of code that works one way or the other, but not both:
Here is the code generated when image is added via content block:
Here is the code that works in the .php file, but does not display when added to the content block:
I'd prefer to use the 2nd piece of code, as I'm working with my site in a temp environment, and want to move it to live server afterwards, therefore, avoiding the need to change pathing throughout the site.
Hope my question is clear enough. Any assist would be appreciated.
Been trying to figure this out on my own for a few days now, so figured I'd better ask the pros.
I've created a stack with a content block that includes html for displaying images. The only way I can seem to get the images to display on my site is to add them via the content block.
When I reference the images via html code, they do not show up. Furthermore, if I place the exact same html code directly into the .php file without using a content block, the images show up then.
Below are the two pieces of code that works one way or the other, but not both:
Here is the code generated when image is added via content block:
<div class="item"><span class="price"></span> <img src="/josh/index.php/download_file/view_inline/15/" alt="k3072891.jpg" width="70" height="70" /></div>
Here is the code that works in the .php file, but does not display when added to the content block:
<div class="item"><span class="price"></span> <img src="<?php echo $this->getThemePath(); ?>/images/menuslider/k3072891.jpg" alt="" width="70" height="70" /></div>
I'd prefer to use the 2nd piece of code, as I'm working with my site in a temp environment, and want to move it to live server afterwards, therefore, avoiding the need to change pathing throughout the site.
Hope my question is clear enough. Any assist would be appreciated.
thanx 12345j, but your suggestion makes sense, but i'm more of a copy/past kind of guy when it comes to php.
if you could spell the code out to me in layman's terms, that would be great.
if you could spell the code out to me in layman's terms, that would be great.
You use "add file" instead "add image" - probaby this is reason of your problem. As you can see in first code you have "download_file" in the path... so this is not link to image, but link for downloading file.
BTW, there are different possibilities to add images, i.e. there is a block: "Image". Of course I don't know your needs, but maybe this will be helpful for you (especially if you can code a little html/css):
http://www.concrete5.org/marketplace/addons/designer-content/...
This add-on is for preparing defined blocks.
BTW, there are different possibilities to add images, i.e. there is a block: "Image". Of course I don't know your needs, but maybe this will be helpful for you (especially if you can code a little html/css):
http://www.concrete5.org/marketplace/addons/designer-content/...
This add-on is for preparing defined blocks.
thanx MysteriousCleon, I'm pretty sure I used the "add image". went back and redid it again just be double check.
i like that add-on you suggested, where has that been hiding :). not what i'm looking for in this situation, but nice tool to have for other blocks i'll be creating.
i like that add-on you suggested, where has that been hiding :). not what i'm looking for in this situation, but nice tool to have for other blocks i'll be creating.
mysterious clean- the download-file link is a generic single page to download any file- image, video, whatever.
grfirst-
i was actually suggesting something too complicated. What you want to do is to copy the entire files directory (root/files) onto the live server concrete5 install, like you would if you were making the site live right now.
Then go to your dashboard, sitewide settings, and file storage location (under environment)
yoursite.com/index.php/dashboard/system/environment/file_storage_locations/
and change the standard files location path to the new files site.
So if your files are currently at /josh/files and for the live site they will be at /files then copy everything in /josh/files to /files. Then go to the dashboard. If it is currently /htdocs/josh/files then change it to /htdocs/files. Does that make sense?
I think at that point everything should just work, without any php or anything.
grfirst-
i was actually suggesting something too complicated. What you want to do is to copy the entire files directory (root/files) onto the live server concrete5 install, like you would if you were making the site live right now.
Then go to your dashboard, sitewide settings, and file storage location (under environment)
yoursite.com/index.php/dashboard/system/environment/file_storage_locations/
and change the standard files location path to the new files site.
So if your files are currently at /josh/files and for the live site they will be at /files then copy everything in /josh/files to /files. Then go to the dashboard. If it is currently /htdocs/josh/files then change it to /htdocs/files. Does that make sense?
I think at that point everything should just work, without any php or anything.
Yes J, that does make sense. Which means I still have to manually add 35 different images 1 by 1 using the "add image" link in the WYSIWYG editor.
Would be so much easier to place some html code in there to reference each.
But definitely the part about moving the files to new remote server makes me sit at ease now.
Would be so much easier to place some html code in there to reference each.
But definitely the part about moving the files to new remote server makes me sit at ease now.
1- i dont think the content block doesn't run any php it finds- so the getThemepath isn't getting run. could be wrong there though.
2- getThemePath will otuput a link to /josh/themes/xyz/image.jpg, not /josh/image.jpg
if you want to get the link to a file use $f = File::getByID($fileID);$f->getPath();