• Content Count

  • Joined

  • Last visited

Community Reputation

47 Excellent

About d'Hinnisdaël

  • Rank
    Jr. Member

Recent Profile Visitors

824 profile views
  1. d'Hinnisdaël

    Would it make sense to add an option to exclude tables from the backup, instead of choosing the tables to include? This would be especially useful with regards to the sessions table. I have a project with a moderate amount of visitors, but 1million+ rows in the sessions table. The backup module fails since the process needs too much memory. If I exclude the sessions table, the export shrinks from 150MB to 30MB, which the server can easily handle. Now, I can already select all tables and leave the table sessions unchecked. However, as soon as I add a field, template, etc., all future backups will be missing that table completely. In that scenario, an exclude option would be the better option. I might just whip up a PR when I find the time, but was wondering if anybody else feels this is necessary or a good idea.
  2. Beautiful, that did the trick. Thanks! Much better than modifying the core search module, and it won't spill over into generic find() calls in the front-end. No idea how I missed the findReady hook in the first place… Final working implementation: // Include unpublished participants in page fields for non-superusers wire()->addHookAfter('ProcessPageSearch::findReady', function(HookEvent $event) { $selector = $event->arguments(0); if(strpos($selector, 'template=participant') !== false || strpos($selector, 'templates_id=76') !== false) { $selector .= ", check_access=0, include=all, status<" . Page::statusTrash; } $event->return = $selector; });
  3. d'Hinnisdaël

    Good point. I've always used it conjunction with some light caching to store the results as JSON.
  4. Unfortunately, this doesn't seem to work for non-superusers. I've been up and down the source of ProcessWire's internal admin search (which powers the page autocomplete input) and it really seems to limit the selection of unpublished pages to superusers. Would be great to have autocomplete inputs respect the Include unpublished setting of a Page field.
  5. d'Hinnisdaël

    For most group-by-property situations, I use Fun with hooks: PageArray::groupBy.
  6. I'm pretty sure that anything beyond basic template selection will not work in autocomplete inputs. I found this comment in the InputfieldPage source regarding custom PHP selectors: Not compatible with PageListSelect or Autocomplete input field types. Also, the field for adding custom code is disabled for autocomplete and page list selects: $field->showIf = 'inputfield!=InputfieldPageAutocomplete|InputfieldPageListSelect|InputfieldPageListSelectMultiple';
  7. From my cursory reading of the source, check_access also seems limited to superusers: // don't allow setting of check_access property, except for superuser if($lowerName == 'check_access' && !$superuser) continue;
  8. Is this an autocomplete inputfield? I just ran into the same problem (a page field not finding unpublished pages for non-superusers, even though Include unpublished is checked). I managed to isolate the issue to ProcessWire's internal admin search that is used behind the scenes of autocomplete fields. Not sure if anything from the last major search update in 3.0.108 might play a role here. This is what's worked for me: Copy the core search module folder from /wire/modules/Process/ProcessPageSearch to /site/modules/Process/ProcessPageSearch/ After lines 422–425 in ProcessPageSearch.module… if(!$status && !$hasInclude && $superuser) { // superuser only $selectors[] = "include=all, status<" . Page::statusTrash; } …insert this: // FIX: include unpublished pages for non-superusers else if(!$status && !$hasInclude && !$superuser) { $selectors[] = "include=all, status<" . Page::statusTrash; } Back in the admin, refresh the module cache (Navigation » Modules » Refresh). ProcessWire will then ask you which version to use for the search module. Pick the one you modified in the /site/ folder. This will basically make it work the same for superusers and non-superusers. I can't report any negative side effects at this point, but in my case it beats promoting all content editors to superusers.
  9. d'Hinnisdaël

    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.
  10. d'Hinnisdaël

    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.
  11. 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.
  12. 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.
  13. d'Hinnisdaël

    @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.
  14. d'Hinnisdaël

    @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.
  15. d'Hinnisdaël

    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.