Limit uploaded photo dimensions or fix them

Howdy all - new to ZP and LOVING it. So nice to have albums be organized as folders in the backend! No one else is doing thais (that i know of)! This makes life easier with the Digital Picture Frame that I built that downloads all the photos from my ZP page and displays them on the wall. :) Which leads me to my question...

Since my photo frame has to have a specific file dimension (1920x1200) to be exact, I would like to limit any upload to be those EXACT dimensions (or allow the user to crop photos in a slick way). Is there a way to do this with a plugin that I don't know about? I've been digging around and haven't come up with anything yet. Any pointers in the right direction would be great, thanks! I'm relatively new to code. I understand some things about code but don't know a whole lot.

Comments

  • acrylian Administrator, Developer
    No, there is no plugin to limit the upload dimensions like that. We only have the quota_manager to limit the number of images per user upload. The best is to resize them before uploading using one of those resize tools outthere (it does often not make sense on site to have images that big)
  • Whoa...wait a minute...what's all this then in the uploader.php file? It's commented out, but it has my exact dimensions! bizarre....I might try enabling it!

    `
    class UploadHandler {

    private $options;

    function __construct($options = null) {
    $this->options = array(
    'script_url' => $_SERVER['PHP_SELF'],
    'upload_dir' => dirname(__FILE__) . '/files/',
    'upload_url' => dirname($_SERVER['PHP_SELF']) . '/files/',
    'param_name' => 'files',
    // The php.ini settings upload_max_filesize and post_max_size
    // take precedence over the following max_file_size setting:
    'max_file_size' => null,
    'min_file_size' => 1,
    'accept_file_types' => '/.+$/i',
    'max_number_of_files' => null,
    'discard_aborted_uploads' => true,
    'image_versions' => array(
    // Uncomment the following version to restrict the size of
    // uploaded images. You can also add additional versions with
    // their own upload directories:
    /*
    'large' => array(
    'upload_dir' => dirname(__FILE__).'/files/',
    'upload_url' => dirname($_SERVER['PHP_SELF']).'/files/',
    'max_width' => 1920,
    'max_height' => 1200
    ),

    'thumbnail' => array(
    'upload_dir' => dirname(__FILE__).'/thumbnails/',
    'upload_url' => dirname($_SERVER['PHP_SELF']).'/thumbnails/',
    'max_width' => 80,
    'max_height' => 80
    )
    */
    )
    );
    if ($options) {
    $this->options = array_replace_recursive($this->options, $options);
    }
    }
    `
  • acrylian Administrator, Developer
    That uploader is an adapted script, I didn't remember that is there actually and I don't think it makes generally sense to enable that.

    But feel free to comment it out if it fits your purpose (you will need to do this again on any update). Or create a ticket so we might consider to add those as plugin options.
  • Besides the fact that you will have to make this change each time there is an update to Zenphoto, it will not do what you have asked.

    Note that the values are max width and height. So all enabling this will do is prevent larger images from being uploaded. Of course you could find where these items are referenced and change the code to check for exact matches.

    But if I understand correctly, all you want is for the downloaded image size to be 1900x1200. It would be possible to make a plugin for the download that "cached" the image at 1900x1200 and provided the download from that cached image. For images that are already that size, no processing will occur. For ones that are not, then Zenphoto will resize them.

    Certainly that would be a much more convenient solution.
  • fretzl Administrator, Developer
    or allow the user to crop photos in a slick way...

    There is of course the `crop_image` plugin which allows you to crop images after uploading them to an album.
Sign In or Register to comment.