WordPress.org

Support

Support » Plugins and Hacks » [Resolved] iimage gallery / random image mashup

[Resolved] iimage gallery / random image mashup

Viewing 2 replies - 1 through 2 (of 2 total)
  • I made some progress on this idea after finding this post on imagemagick center cropping. I was able to add these lines to the random image plugin to get the center cropped images I wanted.

    I would love some feedback! I’m sure the code is ugly and could be full of holes:

    Add the following at line 582

    $SQUARESIZE = 100;
    $convertPath = "/usr/bin/convert";
    $savepath = "[FULL /path/to/cache]";
    $savepathURL = "[FULL http://... URL OF CACHE]";
    $filenamePart = basename($image_src);
    $squarename = "sq_".$filenamePart;
    $filename = $savepath.$squarename;
    if (file_exists($filename)) { } else {
    $squareCommand = $convertPath." \"".$image_src."\" -thumbnail x".($SQUARESIZE*2)." -resize '".($SQUARESIZE*2)."x<' -resize 50% -gravity center -crop ".$SQUARESIZE."x".$SQUARESIZE."+0+0 +repage -format jpg -quality 50 \"".$savepath.$squarename."\"";
    system($squareCommand);
    }

    In line 589 (for me now that I’ve pasted in that code) change from this:

    $image_html = str_replace("%2", "<a href='$post_permalink'><img src='$image_src' alt='$image_alt' $image_attributes /></a>", $image_html);

    to this:

    $image_html = str_replace("%2", "<a href='$post_permalink'><img src='$savepathURL$squarename' alt='$image_alt' $image_attributes /></a>", $image_html);

    I may do some cleanup in the future, but will let the plugin author do any serious stuff if so desired, thus marked resolved, unless someone wants to offer some code suggestions for better WP & PHP poetry.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘[Resolved] iimage gallery / random image mashup’ is closed to new replies.
Skip to toolbar