[resolved] iimage gallery / random image mashup (3 posts)

  1. clarkburbidge
    Posted 8 years ago #

    I would like to try and mash these two plugins. I love that I can get a random image linked to a post from this:


    and the sweet center cropped images from this:


    are layout friendly and very pleasing.

    Can either or be called from the other or can some easy cut and past magic make these do random linked images that are center cropped?

  2. clarkburbidge
    Posted 8 years ago #

    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."\"";

    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);

  3. clarkburbidge
    Posted 8 years ago #

    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.

Topic Closed

This topic has been closed to new replies.

About this Topic