• Content count

  • Joined

  • Last visited

Community Reputation

37 Excellent

About d'Hinnisdaël

  • Rank
    Jr. Member

Recent Profile Visitors

626 profile views
  1. Quick update and version bump to 0.1.0 I updated the module to use the standard ProcessWire variation suffixes. Instead of image.0x200.optim.jpg, optimized images will now be named image.0x200-optim.jpg. Deleting images in the admin or via the API will delete any optimized variations as before, but the process is a lot more straightforward now. I also added a public method $image->removeOptimizedVariations() that does exactly what it says it does.
  2. Dear @horst, thanks for the valuable feedback. Indeed you mentioned a very good point. I suspect I had a slightly different than usual understanding of how to remove image variations created by modules. The current implementation uses a glob (/{page folder}/{original file basename}.*) to delete variations. I'll update the module to use the standard naming scheme — this will have its benefits especially in edge cases, e.g. images will then still get removed if the module is uninstalled or deactivated. Also good idea about having a public method removeOptimizedVariations(). That will be very easy to implement with the previous issue.
  3. In case somebody stumbles upon this thread looking for an ImageOptim plugin, I ended up creating one. It's very much inspired by the TinyPNG module. ProcessWire ImageOptim module To get a sense of where and when to create hooks for optimizing images on upload / resize, these two along with Autosmush could prove helpful.
  4. So I decided to wade into module development and created a wrapper module around ImageOptim, a service that compresses and optimizes images in the cloud. ImageOptim currently handles JPG, PNG and GIF files and, depending on the settings you use, shaves off between 15% and 60% in filesize. Great for bandwidth and great for users, especially on mobile. This module handles the part of uploading images to ImageOptim via their official API, downloading the optimized version and storing it alongside the original image. Download & Info GitHub / Module directory / Readme / Usage Why ImageOptim? There are other image optimization services out there, some of them free, that have outstanding ProcessWire modules. A few things make ImageOptim the best tool for most of my customers: It's not free, i.e. it will probably be around for a while and offers support. However, it's cheaper than some of the bigger competitors like Cloudinary. And it does PNG compression better than any of the free services out there, especially those with alpha channels. Installation Install the module like any other ProcessWire module, by either copying the folder into your modules folder or installing it via the admin. See above for downloads links on GitHub and in the module directory. Requirements To be able to upload images to the service, allow_url_fopen must be set on the server. The module will abort installation if that's not the case. I have only tested the module on ProcessWire 3.x installations. I don't see why it shouldn't work in 2.x, if anyone wants to try it out and report back. ImageOptim account To compress images, you first need to sign up for an ImageOptim account. They offer free trials to try the service. Usage (manual optimization) Images can be optimized by calling the optimize() method on any image. You can pass an options array to set ImageOptim API parameters. $image->size(800,600)->optimize()->url $image->optimize(['quality' => 'low', 'dpr' => 2]) // Set quality to low and enable hi-dpi mode Automatic optimization The module also has an automatic mode that optimizes all image variations after resizing. This is the recommended way to use this module since it leaves the original image uncompressed, but optimizes all derivative images. $image->size(800,600)->url // nothing to do here; image is optimized automatically To change compression setting for single images, you can pass an options array along with the standard ImageResizer options. Passing false disables optimization. $image->size(800, 600, ['optimize' => 'medium']) $image->size(800, 600, ['optimize' => ['quality' => 'low', 'dpr' => 2]]) $image->size(800, 600, ['optimize' => false]) For detailed usage instructions and all API parameters, see the usage instructions on GitHub. Filenames Optimized images will be suffixed, e.g. image.jpg becomes image.optim.jpg. You can configure the suffix in the module settings. Roadmap Asynchronous processing. Not really high on the list. Image variations need to be created anyway, so waiting a few seconds longer on first load is preferable to adding complexity to achieve async optimization. Optimize image variations created by other modules. CroppableImage comes to mind. I don't use any of these, so if somebody wants to help out and submit a pull request — all for it! Add a dedicated page in the setup menu with a dashboard and detailed statistics. ImageOptim's API is very barebones for now, so not sure if that's feasible or even necessary. Stability I've been using this module on production sites for some time now, without hiccups. If you do notice oddities, feel free to comment here or investigate and submit PRs.
  5. @adrian This is great, thanks! I'll take it for a test drive next time I get a chance to upgrade modules on that particular site and report back.
  6. @adrian Sending copies to a list of users would certainly come in very handy! For debugging user registration scripts, I'd usually have to switch Bcc recipients regularly. As for re-branding the Bcc option as "notify other users": sounds good, too. I'm fine with the way it works now and would see the ability to send multiple copies as a priority, but I certainly see your point in simplifying it.
  7. Thanks for implementing the Bcc field, @adrian! It works great on sites using WireMailSmtp. However, on a site using the default WireMail implementation, the bcc() call will fail and abort the whole process. It seems the default WireMail interface does not (yet) have bcc() defined while it is available in WireMailSmtp and others. I'd suggest doing a simple check for the bcc function. For that particular project, I have successfully used the following to fix it. Instead of (line 177): if($this->data['bccEmail'] != '') $mailer->bcc($this->data['bccEmail']); I inserted: if($this->data['bccEmail'] != '') { if (method_exists($mailer, 'bcc')) { $mailer->bcc($this->data['bccEmail']); } else { $mailer->to($this->data['bccEmail']); } } Since the default WireMail will send each to() recipient as a separate mail, the second to() call acts as a de facto bcc address. Maybe that will be enough, maybe you can think of a more sophisticated way of solving it.
  8. I knew I was missing something. Works like charm now, thanks a lot, @Mike Rockett
  9. What's the best way to handle spaces in the original URL? (and whitespace in general) I found that if the requested URL contains spaces, the plugin won't start at all, i.e. there's also no debug screen on matches or compiled jumplinks even when debug mode is turned on. It doesn't seem to make a difference if the links are requested with spaces intact or by directly typing in %20 instead. Also, the pattern itself doesn't make a difference. I tried: GEORGIA GARDNER GRAY.html GEORGIA%20GARDNER%20GRAY.html GEORGIA{space:any}GARDNER{space:any}GRAY.html Is there a preferred way of handling this or am I missing something obvious? Thanks
  10. I had several clients request a version of this module that honors the aspect ratio of a video when using the responsive embed method. For now, the module is using a hard-coded 16/9 ratio. I decided to give it a go myself and forked Ryan's repo. I added functionality to calculate a video's aspect ratio from the oEmbed return values for width and height and made a change to the module's custom db schema to save the aspect ratio. In the (improbable) case the aspect ratio can't be determined, I added a fallback aspect ratio to the module's config. After looking around for a bit, this post about db schema updates for modules with custom databases provided excellent examples on how to handle the schema updates for existing installations. The changes have been tested on several live sites (3.0) and the update went without hiccups. If anyone's interested, here's the commit: https://github.com/[...]/commit/76e9a5e7bba79aef8fae35aaa7a1b7b79e970f90 I'd love to get some feedback on this! Especially from people running this on the 2.7 or 2.8 branch. If all works well, it'd be great to integrate this into @ryan's official repo at some point.
  11. +1 — This is especially important for portfolio sites with multiple large images. Lazyloading is a possibility, but even then progressive loading is visually more satisfying than scanlines. I don't know about the technical details of implementing this in PHP, but I imagine this can't be too complicated. Or do you think this would best be handled by writing a PW module?