class-AnyFile / Basic theme thumbnail cropping

I've customized the basic theme and use the class-video plugin as well as the class-AnyFile plugin. I've noticed the video file thumbnails look as they should but the AnyFile sidecar thumbnails distort a square cropped image. My admin settings have cropping unchecked.

I've seen a few forum entries that bring this up and there is mention of it caused by the basic theme's square thumbnails, as well as adjusting a custom theme's css or i.php. I'm not seeing a clear path to a solution yet.

I'm wondering if I'm missing a forum entry? Forum searches returns 10 entries but there are no page controls (or the controls are hidden?)

Comments

  • I've also worked with printCustomSizedImageThumbMaxSpace() but this makes the video sidecar images square?

  • acrylian Administrator, Developer

    Are you really using the latest Zenphoto version? Actually the thumbs should not be distored anymore as there was a technical issue with sidecar images. In any case you should not (have to) hack core files like i.php.

    It would perhaps be helpful to see the actual issue.

    I'm wondering if I'm missing a forum entry? Forum searches returns 10 entries but there are no page controls (or the controls are hidden?)

    Not sure what you are referring to exactly? Sometimes this forum software also seems to count hidden spam posts for unknown reasons within a topic. That perhaps?

  • We're on Zenphoto 1.5.9.

    Here is an example of the thumbnail issue for a class-video vs class-AnyFile sidecar. https://portal.cubistmediagroup.com/portal/themes/Cubist-basic/images/thumbnail_issue.png

    The top thumbnail uses
    <?php printImageThumb(getAnnotatedImageTitle()); ?>

    The bottom thumbnail uses
    <?php printCustomSizedImageThumbMaxSpace(getAnnotatedImageTitle(),160,90,null,null,null,null); ?>

    This image relates to the forum search:
    https://portal.cubistmediagroup.com/portal/themes/Cubist-basic/images/search-page-controls.png

    I search for 'thumbnail' and 10 results are returned. I find it hard to believe there are not more results. However, there is a section in the code for "PageControls Bottom" that has been hidden.

  • acrylian Administrator, Developer
    edited September 14

    To the images: May very well be a CSS issue. How is that image styled? max Space generates an uncropped image that would fit within 160x90. The default function may create a cropped or uncropped one. The theme CSS would have to match that.

    I would have to try to reproduce this with the plain basic theme. I am pretty sure we did fix an existing bug with from width/height here otherwise.

    Regarding the forum: Indeed that sounds like far too few results. No idea about the hidden page nav. Perhaps another bug with the forum update after the recent upgrade (there were some other bad ones with hidden CSS that even disabled the whole forum…)

    But most will surely be old and rather outdated, lots of things change over times…

  • Thank you. I found if I add 'width:auto;' to the img css it corrects the stretched, cropped image to a square.

    The thumbnails for image files display correctly, as well as for videos. It seems only the class-AnyFile thumbnails are cropped, regardless of unchecking the box to that feature in the theme settings. Do you still support that plugin?

  • acrylian Administrator, Developer
    edited September 15

    Glad you managed it. The best CSS for images to adjust responsively to the box they are in is normally

    display: inline-block;
    max-width: 100%;
    height: auto;
    

    But whatever works ;-)

    It seems only the class-AnyFile thumbnails are cropped, regardless of unchecking the box to that feature in the theme settings. Do you still support that plugin?

    Yes, everything that is included in the release is supported (a few things will become deprecated with 1.6 but not this one).

    Actual custom sidecar files should follow the settings, just the default images are square by default. We will try to reproduce that as soon as possible.

  • acrylian Administrator, Developer

    We did some tests and we can indeed reproduce some issues with default and custom sidecar files. Sadly it is not really consistent so it will take some time to figure this out. Needless to say that it will be in the next release once fixed (which still may take a while)

  • Thank you!

  • acrylian Administrator, Developer

    Sorry took a while due to time issues but there is a fix within 1.6b (master on github) now.

  • Thank you. Could I have a hint at which file was revised? I went over to github and saw the class-video.php was updated recently, but that was working fine before.

    In the meantime, I lifted the following code from class-video.php and added it to the class-AnyFile.php and the thumbnails displayed correctly:


    /**
    * Get a default-sized thumbnail of this image.
    *
    * @return string
    */
    function getThumb($type = 'image') {
    $ts = getOption('thumb_size');
    if (getOption('thumb_crop')) {
    $crop = true;
    $sw = getOption('thumb_crop_width');
    $sh = getOption('thumb_crop_height');
    list($custom, $cw, $ch, $cx, $cy) = $this->getThumbCropping($ts, $sw, $sh);
    } else {
    $crop = false;
    $sw = $sh = $cw = $ch = $cx = $cy = null;
    }
    $wmt = getOption('AnyFile_watermark');
    if (empty($wmt)) {
    $wmt = getWatermarkParam($this, WATERMARK_THUMB);
    }
    if ($this->objectsThumb == NULL) {
    $mtime = $cx = $cy = NULL;
    $filename = makeSpecialImageName($this->getThumbImageFile());
    if (!getOption('AnyFile_watermark_default_images')) {
    $wmt = '!';
    }
    } else {
    $filename = filesystemToInternal($this->objectsThumb);
    $mtime = filemtime(ALBUM_FOLDER_SERVERPATH . '/' . internalToFilesystem($this->imagefolder) . '/' . $this->objectsThumb);
    }
    $args = getImageParameters(array($ts, $sw, $sh, $cw, $ch, $cx, $cy, null, true, $crop, true, $wmt, NULL, NULL), $this->album->name);
    return getImageURI($args, $this->album->name, $filename, $mtime);
    }

    /**
     * Returns an array with widht and height the sidecar thumb image
     * 
     * @since ZephotoCMS 1.5.8
     * 
     * @return array
     */
    function getThumbDimensions() {
        if (!is_null($this->thumbdimensions)) {
            return $this->thumbdimensions;
        }
        $imgfile = $this->getThumbImageFile();
        $image = zp_imageGet($imgfile);
        $width = zp_imageWidth($image);
        $height = zp_imageHeight($image);
        return $this->thumbdimensions = array(
                'width' => $width,
                'height' => $height
        );
    }
    

  • acrylian Administrator, Developer

    The commit that fixed the issue was this simple one:
    https://github.com/zenphoto/zenphoto/commit/b729fa02c0383ac806453dba43b7518954aad2d3

    We generally don't recommend to use just bits especially since in this case the master on GitHub is 1.6a so there might be a few more interconnected changes that break things elsewere. We naturally don't test that :-)

Sign In or Register to comment.