WordPress.org

Ready to get started?Download WordPress

Forums

Events Manager
[resolved] How to use a resized but not cropped version of event image (9 posts)

  1. Daedalon
    Member
    Posted 1 year ago #

    We now use placeholders like "#_EVENTIMAGE" or "#_EVENTIMAGE{400,400}" to display event images. The first one loads the image in full, and while it's possible to alter the visibility with CSS and HTML, the client's browser always loads every megabyte of the full image. The second one uses TimThumb to resize and crop the image to the specified size.

    How to show a resized image preserving the original aspect ratio (is not cropped)? The specified dimensions would thus be maximum dimensions. For example "#_EVENTIMAGE{400,400,nocrop}" that would show a 1000x500 as a 400x200 image.

    Doesn't TimThumb support a parameter "zc=0" for not cropping the image, only resizing it? http://www.binarymoon.co.uk/demo/timthumb-zoom-crop/ If not, is there a custom shortcode example available for this that we could use?

    http://wordpress.org/extend/plugins/events-manager/

  2. Marcus
    NetWebLogic Support
    Plugin Author

    Posted 1 year ago #

    something we could consider int he future but atm you can now allow WP to do that for you by using the new WP thumbnails option under Settings > General > Performance Optimization

  3. Daedalon
    Member
    Posted 1 year ago #

    On our site we would want certain images to be cropped and certain images to not be cropped. We would prefer that this would be done via WP thumbnails for performance, but as long as both can be used at the same time, we don't mind if either or both are done via TimThumb.

    Would it be possible for you to add support for "nocrop" and "crop" parameters for #_EVENTIMAGE?

  4. Marcus
    NetWebLogic Support
    Plugin Author

    Posted 1 year ago #

    yes, but probably not anytime soon, we've already got a lot to work through atm

  5. webaware
    Member
    Posted 1 year ago #

    @Daedalon: if you want a bit more control, register a custom image size (with / without crop) and hack this snippet to use that custom image size instead of thumbnail.

  6. Marcus
    NetWebLogic Support
    Plugin Author

    Posted 1 year ago #

    @webaware, nice snippet!

  7. Daedalon
    Member
    Posted 1 year ago #

    Thanks, webaware! Looks excellent, will try that.

  8. Daedalon
    Member
    Posted 1 year ago #

    I got it working after a few adjustments.

    1. Instead of a full copy-paste, I copied only the most central part of the snippet and used it inside the switch-case structure for custom placeholders as per http://wp-events-plugin.com/tutorials/create-a-custom-placeholder-for-event-formatting/.

    For that to work I had to change "$result" to "$replace".

    2. Thumbnails had to be regenerated for the new custom image size before an already-added event's image started displaying properly. I used the excellent Simple Image Sizes plugin. This plugin can also be used to create the custom image size without having to touch the theme's functions.php file.

    Before regenerating the thumbnails the default full-size image was loaded and then resized in the browser.

    Thanks again for the help, webaware!

  9. webaware
    Member
    Posted 1 year ago #

    @Daedalon: excellent, good work. I love it when a plan comes together :)

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic

Tags

No tags yet.