WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] [Plugin: Scissors] Small Resizing Feature Request (5 posts)

  1. alkafy
    Member
    Posted 5 years ago #

    As you type the units to resize one dimension of an image, it would be great if the other dimension was dynamically calculated and displayed. Not a huge deal - it would just be a little helpful. Otherwise, incredibly useful plugin. Thank you.

  2. stephanreiter
    Member
    Posted 5 years ago #

    Sounds good and should be simple to implement. Thanks for the suggestion!

  3. alkafy
    Member
    Posted 5 years ago #

    I'm sure you could do this more elegantly, but I hacked together a solution:

    Line 768 scissors.php

    $resizeValue = "<input style='width:3em;text-align:center;' type='text' id='scissorsSide-$postId' value='640' onkeyup=\"scissorsCalcResize($postId)\" />";

    New Function in scissors.js

    function scissorsCalcResize(id) {
    var resizeDim = Number(jQuery('#scissorsSide-'+id).val());
    var dimensions = jQuery('#scissorsSize-'+id).html().split(' × ');
    var width = Number(dimensions[0]);
    var height = Number(dimensions[1]);
    var resizeMode = jQuery('#scissorsMode-'+id).val();

    if (resizeMode!='width' && resizeMode!='height') {
    var longSide = 'width';
    var shortSide = 'height';
    if (width<height) {
    longSide = 'height';
    shortSide = 'width';
    }
    if (resizeMode=='long') {
    resizeMode = longSide;
    }else {
    resizeMode = shortSide;
    }
    }

    if (resizeMode=='width') {
    height = Math.floor((resizeDim/width)*height);
    width = resizeDim;
    } else {
    width = Math.floor((resizeDim/height)*width);
    height = resizeDim;
    }

    if (jQuery('#newSizes-'+id).length==0) {
    jQuery('#scissorsSize-'+id).after('<span id="newSizes-'+id+'"></span>');
    }
    jQuery('#newSizes-'+id).html(' Calculated Size: '+width+' x '+height);
    }

  4. stephanreiter
    Member
    Posted 5 years ago #

    Implemented and part of the new development version (find it under 'other versions'). Please test it and if you're satisfied mark this thread as resolved. Thanks!

  5. alkafy
    Member
    Posted 5 years ago #

    Nicely done. Thank you very much.

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags