Getimagesize random

Have a question or a suggestion about a 3rd party addon module or plugin?
Let us know here.
Post Reply
pierrepercee
Forum Members
Forum Members
Posts: 153
Joined: Thu Jan 10, 2013 8:02 am

Getimagesize random

Post by pierrepercee »

Hello,
I have a problem with the Getimagesize() function used in a gallery module template.
Each time the gallery is loaded, only the sizes (width and height) of a few images are retrieved, sometimes all of them. It's completely random and not necessarily the same images. I obviously tried with different images from different sources

Code: Select all

<ul>
{foreach from=$images item=image}
{$imagesize=getimagesize($image->file)}
<li> name : {$image->file} <em>width :</em> {$imagesize[0]}- <em>height:</em> {$imagesize[1]} </li>
{/foreach}
</ul>
Ctrl+F5 gives randomly
Image
Image
Image

I spent hours there and I admit I don't understand what's going on.... :(
User avatar
DIGI3
Dev Team Member
Dev Team Member
Posts: 1657
Joined: Wed Feb 25, 2009 4:25 am
Location: Victoria, BC

Re: Getimagesize random

Post by DIGI3 »

getimagesize() is a php function, so perhaps you're running out of php memory? Check the php error log, and the admin log, to see if there's any clues. It could also be your host limiting the number of processes.
Not getting the answer you need? CMSMS support options
pierrepercee
Forum Members
Forum Members
Posts: 153
Joined: Thu Jan 10, 2013 8:02 am

Re: Getimagesize random

Post by pierrepercee »

Thanks Digi3,
.
I have a failed to open stream error: connection refused.
I know it's a php function. I created a php file at the root of my site and a directory of images ( many).

Code: Select all

<?php

function walkDir($path = null) {
    if(empty($path)) {
        $d = new DirectoryIterator('./testqdima');
    } else {
        $d = new DirectoryIterator($path);
    }

    foreach($d as $f) {
        if(
            $f->isFile() && 
            preg_match("/(\.gif|\.png|\.jpe?g)$/", $f->getFilename())
        ) {
            list($w, $h) = getimagesize($f->getPathname());
            echo "<p>".$f->getFilename() . " Dimensions: " . $w . ' ' . $h . "</p>";
        } elseif($f->isDir() && $f->getFilename() != '.' && $f->getFilename() != '..') {
            walkDir($f->getPathname());
        }
    }
}

walkDir();

?>
It works perfectly, all images are alway processed.

My client, despite my recommendation to reduce the images to 1200x X before sending, tried with 15mb images. Is it possible that the host has reduced resources on a particular directory ?
User avatar
DIGI3
Dev Team Member
Dev Team Member
Posts: 1657
Joined: Wed Feb 25, 2009 4:25 am
Location: Victoria, BC

Re: Getimagesize random

Post by DIGI3 »

I haven't used the gallery module in a while, is $image->file the path or the url? If it's the latter, that could explain the difference between your function using the path and the gallery template. I'm just guessing at this point though, it's a bit outside my wheelhouse.
Not getting the answer you need? CMSMS support options
pierrepercee
Forum Members
Forum Members
Posts: 153
Joined: Thu Jan 10, 2013 8:02 am

Re: Getimagesize random

Post by pierrepercee »

Hello,

I asked the question on stackoverflow, it is indeed a problem with the host(against DDOS attack). I use Photoswipe which is probably the most advanced jquery module for gallery. I will try to ask the developer to add the width and height in the database.
I'm not sure... ;)
Post Reply

Return to “Modules/Add-Ons”