create a file object by the files path?

Permalink
Hi folks,
I installed the "random image block"
The "view.php" works with a variable: "$imagePath"
(that means: "/application/files/1815/1161/6070/enigokwag_eki.jpg")
Now I need to get the description of the file at the end of that link.

I tried: "$f = (getFileID($imagePath);" but I guess this is complete nonsens...
Looking forward for some help.
Mathias

MathiasB
 
mnakalay replied on at Permalink Reply
mnakalay
what version of C5 are you on?
MathiasB replied on at Permalink Reply
MathiasB
I am on # concrete5 Version
Core Version - 5.7.5.13
Steevb replied on at Permalink Best Answer Reply
Steevb
Do you want 'Title' or 'Description' of file?

Line nine of view:
Title:
<img src="<?php  echo $imagePath ?>" alt="<?php echo $fv->getTitle(); ?>"/>


Description:
<img src="<?php  echo $imagePath ?>" alt="<?php echo $fv->getDescription(); ?>"/>


Does that help?
MathiasB replied on at Permalink Reply
MathiasB
Wow. Goody!!!!
Thank You! That works great.
I even can put the "$fv" in a different div to display the description in a little overlay.
<?php 
   if (isset($error)) {
      echo $error;
   } else {
      ?>
      <img src="<?php  echo $imagePath ?>" />
      <?php 
   }
   ?>
<div class="logo">
<?php echo $fv->getDescription(); ?> 
</div>


But how can php know, which file description is needed? Is it the last one in the code before?

Best Mathias
mnakalay replied on at Permalink Reply
mnakalay
that's because the plugin's developer had a good idea of making $fv available to the view but because it's not used there, you would have had to check the controller to find out about it.
mnakalay replied on at Permalink Reply
mnakalay
if you go through the controller and see this kind of lines:
$this->set('somevariable', 'value of the variable');

Then $somevariable is available to the view