Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
Get images from a txp category into an array dynamically....Any Ideas?
Playing with a script and would like to create a simple array from a txp category of images. I would need to get : “location/file-name.ext,width,height” from the database, and not sure the easiest/cleanest way to start hashing this out. So I figured I would throw it out first.
<code>var photoArray = new Array(
new Array(“images/image1.jpg”, “500”, “331”),
new Array(“images/image11.jpg”, “500”, “377”),
new Array(“images/image8.jpg”, “490”, “400”)
);
</code>
Offline
Re: Get images from a txp category into an array dynamically....Any Ideas?
$photoArray = safe_rows('id, ext,w,h','txp_image','category="a-cat"');
Contains images for a-cat. The path to image you can get by
<pre><code>
for($i=0;$i < count(photoArray );$i++){
extract($photoArray[$i])
$photoArray[$i][‘path’] = hu.$img_dir.’/’.$id.’.’.$ext;
}
</code></pre>
Offline
Re: Get images from a txp category into an array dynamically....Any Ideas?
Thanks Bastian, I have been looking at the back end of your lightbox to try and dissect it. I am trying to get a version of Moo Show working with a test installation I have. So I will play with your snippet and see what I can hack together.
Thanks!
Offline