Image File Url

Permalink 2 users found helpful
I'm working with the "pronews" add-on and I'm trying to figure out how to use the thumbnails to generate a larger image preferably in a pop-up fancy box solution. Right now i'm trying to find the right path to link to.

I'm using this at the moment...

<a id="example2" href="/index.php/download_file/-/view_inline<?php echo $image; ?>" > <?php echo '<img alt="thumbnail" src="'.$image.'" style="float:left; border:none; padding-right: 20px; padding-left:10px; "/>';?> </a>


This is giving me a blank white page with the cache number in the url...

Example: /index.php/download_file/-/view_inline/files/cache/bfd985e2511cc667071433f695c46cc5.png

Is there anyway to tweak this so that I can get the actual image to show up in a full version?

Any help would be appreciated!

bryanlewis
View Replies: View Best Answer
cherrycake replied on at Permalink Reply
cherrycake
what's the $image? an id, an object or an array?

looks like you are missing the last / after view-inline..

if $image is the actual id of the image (fID), then this would show the full sized image:

<a href="/index.php/download_file/-/view_inline/<?php echo $image; ?>">
<img src="the thumb source">
</a>


sidenote, if you're using c5 v. 4+ you don't need the dash anymore in the link.. so /download_file/view_inline/ is fine..
jordanlev replied on at Permalink Reply
jordanlev
If $image is what's being used for the thumbnail, you're not going to want to use it for your popup also -- you'll just get a popup of a tiny thumbnail that's no bigger than what the user just clicked on.

What exactly are these thumbnails? Do you know for a fact that larger versions exist in the system somewhere? It's possible that the thumbnails are the only versions of those images (but I don't know because I'm not sure what they are exactly -- haven't used ProNews yet).
cherrycake replied on at Permalink Reply
cherrycake
i just realized that too after i posted my reply.

haven't used the addon either but i was assuming he was talking about the 2/3 thumbnails that gets autogenerated whenever uploading an image file in the file manager. if that's the case, the original image object has references to the thumbnail paths as well as it's own path obviously and the thumbnail images themselves are never treated as images but only paths..
bryanlewis replied on at Permalink Reply
bryanlewis
Thanks for the help guys! I should have explained myself a bit better. Sorry about that.

Yes, I'm certain that their are larger versions of the thumbnails in the system. The thumbnails are being generated by the following I believe.

<?php  
   for ($i = 0; $i < count($cArray); $i++ ) {
      $cobj = $cArray[$i]; 
      $title = $cobj->getCollectionName(); 
      $newsDate = $cobj->getCollectionDatePublic('M d, Y  -  h:m a');
      if ($cobj->getCollectionDatePublic() < date(DATE_APP_GENERIC_MDY_FULL) ){
      $imgHelper = Loader::helper('image'); 
      $imageF = $cobj->getAttribute('thumbnail');
      if (isset($imageF)) { 
          $image = $imgHelper->getThumbnail($imageF, 150,90)->src; 
      } 
   ?>


I pretty sure Jordan is correct by saying I don't want to use $image for the large image since its being generated by the thumbnail hence me getting a thumbnail for a popup image.

I'm not for sure what function I should use then to grab those bigger images since this is the case. I'm not the best at php but I know my way around it a bit. With that said I'd imagine that there is some sort of C5 function I could use to grab it maybe?

Here is a url to the whole view.php file.http://pastie.org/1102035 If you guys have any ideas I'd really appreciate them. I"ll try out anything.

Thanks again for the help!
bryanlewis replied on at Permalink Reply
bryanlewis
I can't figure out why <?php echo $image ?> is showing the cache file.

/index.php/download_file/-/view_inline/files/cache/bfd985e2511cc667071433f695c46cc5.png

if its suppose to show the thumbnail. Thats where i'm getting confused.
jordanlev replied on at Permalink Best Answer Reply
jordanlev
Bryan,
$image is the result of the call to $imgHelper->getThumbnail() -- the thumbnail function automatically caches its output so it doesn't have to recreate the thumbnail on every page request.
So basically that $image variable is a red herring in this case -- what you want to focus on here is the $imageF variable, which is passed TO the getThumbnail() function.

Looking at the code, it looks like that image comes from a page attribute (called "thumbnail", just to confuse things). So you should be able to do this to get the path to that full-size image:
<?php
$src = $imageF->getRelativePath();
$size = @getimagesize($imageF->getPath());
$width = $size[0];
$height = $size[1];
?>
<img src="<?php echo $src; ?>" width="<?php echo $width; ?>" height="<?php echo $height; ?>" />


OR, in your specific situation where you want a lightbox, you should do this:
<?php
$src = $imageF->getRelativePath();
$size = @getimagesize($imageF->getPath());
$width = $size[0];
$height = $size[1];
$fv = $imageF->getRecentVersion();
$title = htmlentities($fv->getTitle());
$description = htmlentities($fv->getDescription());
?>
<a href="<?php echo $src; ?>" class="lightbox" title="<?php echo $description; ?>">
   <img src="<?php echo $image; ?>" width="150" height="90" alt="<?php echo $title; ?>" border="0" />
</a>
bryanlewis replied on at Permalink Reply
bryanlewis
Okay, this is great! That is exactly what I need. I was getting thrown off by $image and $imageF!

Thank you so much! That did the trick! I really appreciate it!
RadiantWeb replied on at Permalink Reply
RadiantWeb
sorry, I was unplugged there for a bit.

Yes, you have that correct.

The "thumbnail" attribute really is just a a regular size image. The reduction happens in the block view as you see there.

$imageF is the object. $image, in that case, is the thumbnail function.

Chad
CIRESatCU replied on at Permalink Reply
Can you share your code please? I'm having a hard time figuring out what code to replace exactly; I keep getting errors and just want to avoid using cached image files for the thumbnail and use the relative path the file uploaded.

Thanks!
CIRESatCU replied on at Permalink Reply
Hi,

I am having this exact problem but I am definitely lost on this... if only I were a programmer, then maybe I'd understand what's going on with the code.

I do not want to use the cached thumbnail, but instead use the actual thumbnail we've uploaded at 100px by 100px. It's not huge, but the cached version quality is much worse than the actual uploaded image.

I have this code
if (count($cArray) > 0) { ?>
   <!-- <div class="ccm-page-list" id="news-list"> -->
   <?php  
   for ($i = 0; $i < count($cArray); $i++ ) {
      $cobj = $cArray[$i]; 
      $title = $cobj->getCollectionName(); 
      $newsDate = $cobj->getCollectionDatePublic(DATE_APP_GENERIC_MDY_FULL);
      $imgHelper = Loader::helper('image'); 
      $imageF = $cobj->getAttribute('thumbnail');
      if (isset($imageF)) { 
          $image = $imgHelper->getThumbnail($imageF, 150,90)->src; 
      } 
   ?>


and then further down I have this code which displays the thumbnail on the page

<?php 
      if(!empty($image)){
         echo '<a href="'.$url.'" >';
         echo '<img class="imageLeft" src="'.$image.'" alt="news_image"/>';
         echo '</a>';
      }
   ?>


I read your post, but I don't understand how to use it and where to put the code. If you can help, I'd greatly appreciate it!

Main goal: not use cached thumbnail images, but the full size images instead!

Thank you!
-Kiki
jordanlev replied on at Permalink Reply
jordanlev
You need to be operating on the $imageF variable, not the $image variable (it's a shame they are named so confusingly... makes it hard to figure out what's going on).

So in your code, where you have this:
if (isset($imageF)) {
    $image = $imgHelper->getThumbnail($imageF, 150, 90)->src;
}

...replace it with this:
<?php
$src = $imageF->getRelativePath();
?>

...then down in your markup keep it the same as you have it except replace the two "$image" variables with "$src" instead.

If that doesn't work, then you might need to post a support request to the addon's marketplace page.

Good luck,
Jordan
CIRESatCU replied on at Permalink Reply
Thanks Jordan! That did the trick. I appreciate your response to this question!!!

-Kiki