Recently Browsing 0 members
No registered users viewing this page.
As threatened in the Pub sub forum in the "What are you currently building?" thread, I've toyed around with Collabora CODE and built file editing capabilities for office documents (Libre-/OpenOffice formats and MS Office as well as a few really old file types) into a PW module.
If you are running OwnCloud or NextCloud, you'll perhaps be familiar with the Collabora app for this purpose.
Edit office files directly in ProcessWire
Edit your docx, odt, pptx, xlsx or whatever office files you have stored in your file fields directly from ProcessWire's page editor. Upload, click the edit icon, make your changes and save. Can be enabled per field, even in template context.
Currently supports opening and saving of office documents. Locking functionality is in development.
See the README on GitHub for installation instructions. You should be reasonably experienced with configuring HTTPS and running docker images to get things set up quickly.
Pull requests are welcome!
Here is a short demonstration:
By Robin S
An Images field allows you to:
Rename images by clicking the filename in the edit panel or in list view. Replace images, keeping metadata and filename (when possible) by dropping a new image on the thumbnail in the edit panel. Introduced here. But neither of these things is possible in File fields, which prompted this module. The way that files are renamed or replaced in this module is not as slick as in the Images field but it gets the job done. The most time-consuming part was dealing with the UI differences of the core admin themes. @tpr, gives me even more respect for the work that must go into AdminOnSteroids.
Most of the code to support the rename/replace features is already present in InputfieldFile - there is just no UI for it currently. So hopefully that means these features will be offered in the core soon and this module can become obsolete.
Files Rename Replace
Allows files to be renamed or replaced in Page Edit.
Install the Files Rename Replace module.
If you want to limit the module to certain roles only, select the roles in the module config. If no roles are selected then any role may rename/replace files.
In Page Edit, click "Rename/Replace" for a file...
Use the text input to edit the existing name (excluding file extension).
Use the "Replace with" select to choose a replacement file from the same field. On page save the file will be replaced with the file you selected. Metadata (description, tags) will be retained, and the filename also if the file extensions are the same.
Tip: newly uploaded files will appear in the "Replace with" select after the page has been saved.
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
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.
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.
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.
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
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.
Optimized images will be suffixed, e.g. image.jpg becomes image.optim.jpg. You can configure the suffix in the module settings.
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.
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.