These forums are provided for community interactions only. For official support please submit a support ticket.
You are not logged in.
Is there currently a way to ascertain the dimensions of a given director-generated image dynamically? Here's what i'm trying to do....
I would like to capture the exact height/width dimensions of an image as it gets loaded from Director... so that... I can then use those dimensions as variables that get inserted into some inline CSS styles on other (corresponding) elements that relate to the image. Wow, I hope that isn't too confusing.
e.g.:
<div class="caption" style="top:-642px;"> <div class="captionInner"> <span class="imageTitle"><?php echo $image->title ?></span> <span class="imageCaption"><?php echo $image->caption ?></span> </div> </div>
...so in this case... I need to somehow get the image HEIGHT dimension so that I can use some simple math to arrive at the "-642px" number. (I'm using some relative positioning to overlay captions on top of my images. If each image was the exact same height, it would be easy. But I don't want to be limited to having every image be the same height.)
Again, sorry if this is convoluted or very noobish. Any help at all would be much appreciated. Thanks.
Ben
Offline
There are some methods built into PHP that can help you do this... not sure how you would use it in this case... but just for future reference:
http://us2.php.net/manual/en/function.imagesx.php
http://us2.php.net/manual/en/function.imagesy.php
Offline
Thanks for the tips! I'll check that out and see what I can come up with...
Offline
Perhaps if thedirector API had a method for resolving the director source url to a realPath for the image, the cached image. Not sure how possible that would be but it would make all sorts possible
open up a whole new range of possiblites
Offline
I agree. Seems like that would make things a lot simpler, and bit easier to work with.
Offline
well, here's what I did for now (that works)...in case anyone's interested...
<?php list($width, $height) = getimagesize($image->large); ?>
then just used a simple equation to accomplish my relative positioning shift...
$captionVertShift = $height+18;
and then inserted the variables $captionVertShift and $height in the XHTML accordingly.
<div class="caption" style="top:-<?php echo $captionVertShift;?>px;">
Offline
I'll see if we can return the width and height of the optimized image. The above can be a little (or a lot) slow if the image hasn't been created yet.
Offline
Yes, indeed it is slow. :-) In fact, I just isolated the slowness that I referred to in my other post, to this issue.
If there was a way to return the dimensions that would be awesome.
As always, thanks Brad.
Ben
Last edited by bd1121 (2008-04-19 07:51:26)
Offline
I hate to pester (as I know how hard you guys are working on this baby) -- I just wondered if by chance we may be getting a bit closer to having another round of goodness come our way with the API -- I'm *this* close to having my new site cranking on all cylinders, but I'm waiting for this fix (hoping that there is one) before I turn on some of the features on it. I can do it (slowly) like I showed above, but everything else so far is so fast with the API, I hate to bog down the performance on the site with a hack-y fix like the one above.
Again, not at ALL unhappy with the progress or features so far... just putting feelers out there for when we might get some more. (?)
:-) Thanks,
Ben
Offline
We're working on it, remember...it's a beta ![]()
Beta 5 is getting very close to being released, and will feature a revamp of the API with more features and better docs. Stay tuned...
Offline
Woo hoo! Yes, beta it is. But it's a lovely one. :-)
Thanks for the update.
Offline
Brad,
I've been picking through the new API info (which is great by the way)... and I don't yet see a way to return the width and height of the optimized images -- although, I'm very aware that I may be missing something...
Is this (yet) possible? If so, could you point me in the right direction?
thanks,
Ben
Offline
Ben - Check the examples on this page, it shows how to access the w/h of optimized imagery:
http://wiki.slideshowpro.net/SSPdir/API-DirPHP-OnDemand
Offline
Aaaah. I see it now. I had seen that page, but had misread/misunderstood it at first. Making sense now. Thanks Brad.
Offline