Get the path of an image uploaded through C5 interface

Permalink
Hello there!
I am trying to implement a certain image, that is changeable through the C5 interface. I was thinking of giving a div element an inline style, with PHP getting the path of the (background)image. The image is uploaded via C5 dashboard with a specific name. How can I get path of this image?

 
Stratus3D replied on at Permalink Reply
Go to the file manager and left click on the image. Click "View" from the drop-down menu. A popup window will appear with the full size image in it. Right click on the image and choose something like "Copy URL" (Most browsers have some type of option in the menu that allows you to copy the image url. if your browser does not allow you to copy the url you can always use the developer tools to select the image and view the url).
szucslaszlo replied on at Permalink Reply
Hey there! Thanks for the reply, although it is not the kind of solution I am looking for - mea culpa, I wasn't clear enough on this.
I am trying to make a theme with the capability of dynamically changeable images, which can be easily changed by uploading an image with a specific filename - ofcourse, this means the filenames are unique. Would you perhaps know a way to achieve this, too?
Stratus3D replied on at Permalink Reply
There are a couple of options you have:

1. Use something like
<img src="<?php echo $this->getThemePath()?>/image/photofilename.png">
and place the file in the template's image directory. The disadvantage to this is that users cannot change the photo via the interface. They must always use FTP to change the photo

2. Use a piece of code like <img src="<?php echo($page->getAttribute('page_image')->getVersion()->getRelativePath());?>" >. The disadvantage to this is you would need to add a page_image attribute to the page before an image would show up. You could also use

<img src="
<?php 
$img_path = $page->getAttribute('page_image')->getVersion()->getRelativePath());
if ($img_path ) {
  echo $img_path;
} else {
  echo $this->getThemePath() . 'image/filename.png';
}
?>" >


This would load a default image stored in the template if no page_image attribute were specified.
szucslaszlo replied on at Permalink Reply
Hi! Unfortunatelly these are both unpreferred solutions in my situation. The user does not have the skills to manipulate files through FTP safely, and I want a simply an elegatn solution, where the user has to change one file through C5, and the changes are made on all the sites. Page attributes have to be set for each page/page_type, which can be tedious on a large site. Is there no way to achieve this kind of functionality directly? :(
Erik74 replied on at Permalink Reply
How about implementing a stack?
A stack get updated on all pages at the same time.
szucslaszlo replied on at Permalink Reply
Hm. I have not thought of that option, because the site is using an older version of C5. The old dashboard appearance was preferred. I will try it out on localhost, and give feedback if this is what I was looking for!
Erik74 replied on at Permalink Reply
In old versions the scrapbook is the same thing
yawstick replied on at Permalink Reply
New to concrete but have played with quite a few CMS packages and concrete has the most bazaar directory structure of anything I've seen.
After an install you have the concrete dir with a bunch of empty dir's and then another concrete dir with stuff in them. Then you have the whole numbered directories where images are buried for some reason. Why do you not have a main images directory for content? Are the empty dir's at the top for putting in overides for the ones below?
Stratus3D replied on at Permalink Reply
Not directly. But you could achieve the same functionality this way in Concrete 5.4:

First, where you want the image to display in the template add this:

$img = Block::getByName('Image Block Name'); 
if( is_object($img) ) $img->display();


Then go to the dashboard and create a image block in the scrapbook named 'Image Block Name' or whatever the name is of the block you are selecting with Block::getByName(). The image block should then be displayed in the template wherever the code above is inserted.