• Two com_resize Fixes

    I think com_resize is a great plugin. But, version 0.1.2 is new and could use
    some minor patching. For example, it does not work for img tags that use
    single quotes instead of double quotes. A quick fix for that is to modify
    resize.php (around line 28) and change this:

    preg_match_all(‘#<img.*src=”(.*)”.*/>#isU’, $text, $image_matches);

    to this:

    preg_match_all(‘#<img.*src=[“\’](.*)[“\’].*/>#isU’, $text, $image_matches);

    This is not a perfect fix as it will not work if (for some reason) there is a quote
    character embedded in the img tag’s src attribute.

    Another improvement is to modify the code so that it works when the width
    is specified but the height is not (it already works fine, though, when the
    height is specified but the width is not). To fix this just initialize the variable
    $dimensions before the two conditionals that set the width and height:

    // added this fix for when width is specified but height is not
    $dimensions = “”;

    I hope these fixes (or improved versions of them) make it into the next version.

    Robert DeBenedictis, PRX.org

    http://ww.wp.xz.cn/extend/plugins/com-resize/

Viewing 2 replies - 1 through 2 (of 2 total)
  • Thanks Robert! I implemented the first fix (also see my blog where you left a note). But the second: the height/width problem. Well, it works for me ™. If you have some html-code to demonstrate what’s going wrong I’ll update it. But I can’t find the mentioned flaw.

    Thread Starter debenedictis

    (@debenedictis)

    Hi Leon,
    Thank you for your diligence in fixing the bugs I pointed out.
    The html code to demonstrate the “Height Not Specified” bug
    would be a post with code like this:

    <img src='let-x.jpg' height=20 width=20>
    <img src='let-x.jpg' width=20>

    The reason this doesn’t work is that when there is a post with
    multiple img tags the $dimensions variable is only reset when
    the height is specified. If only the width is specified then the
    $dimensions variable remains from the previous img and gets
    the new width appended to it:

    if ($height) {
        $dimensions = "&h=$height";
    }
    if ($width) {
        $dimensions .= "&w=$width";
    }

    Does that make sense?

    Robert

Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘[Plugin: com_resize] Fix for Single Quotes and Height Not Specified’ is closed to new replies.