Jump to content
matjazp

Auto Smush

Recommended Posts

Is the bellow error referring to the resmush.it server?

Quote

reSmush.it (auto): Error optimizing C:/laragon/www/mysite/site/assets/files/4100/test_a_1548188586.-thumbnail.400x0.jpg, 500 Internal Server Error (possible request timeout)

 

Share this post


Link to post
Share on other sites
2 hours ago, PWaddict said:

Is the bellow error referring to the resmush.it server?

Yes, this is the response from the server.

8 hours ago, Tom. said:

I never knew it didn't do this already?! I haven't been optimising me images when I thought they were optimised haha! I noticed the module had been updated today, however it doesn't seem to be this version. I'm happy to help test it.

Yeah... It never crossed my mind that I should mention this somewhere, sorry. I don't like to update on github when I'm not sure it works and this change was just a quick fix...

9 hours ago, adrian said:

One other thought - I am not sure I actually want it to optimize on "add" via the API - that suggests to me that  it would optimize the uploaded image which I don't want. I only want resized / cropped images optimized. I think there should be an option to prevent optimizing on API add if desired.

Make sense. Give me some time to think about possible solutions. Probably the best option would be separate list of options for admin (backend?), what we have now, and for API (frontened?). 

  • Like 1

Share this post


Link to post
Share on other sites

Hi matjazp!

You and tpr created a really great modul, I have installed 10+ sites, now, and Page Speed loves, too. 🙂

But. Now, one of hosting provider, I use, sent me an email (Linux based):

 

Quote

 

Scanning /home/abcd:

'/home/abcd/public_html/site/modules/.AutoSmush/windows_binaries/svgo.exe' # ClamAV detected virus = [Win.Malware.Jaik-6917323-0] (md5sum:da85160658dca08df050f2075ae54f29)

I have deleted the binaries, aren't need for Linux, so, it's only an information for you..

Regards,
Tamas

  • Like 1

Share this post


Link to post
Share on other sites

@tthom_pw thanks for the report, I'm aware of this. The problem is that there is no svgo binary for windows. So I had to take svgop library, but there are problems too: it's 35 MB binary that takes different parameters. I had to convert/pack svgop to svgo using a batch file and the result is a UPX binary that is always treated as suspicious by antivirus software. I'll most likely remove support for svg on windows in the next release.

Share this post


Link to post
Share on other sites
1 hour ago, matjazp said:

UPX binary that is always treated as suspicious by antivirus software

This is not always true, my portable launcher called yaP is not treated as suspicious when upxed, otherwise it is. Interestingly about 5 yrs ago the case was the opposite, I skipped upxing the main binary because virustotal reported several threats. So... you just never know 🙂

Share this post


Link to post
Share on other sites

Is it possible to prevent optimizing on upload on specific field via hook? Nevermind, don't need it anymore.

Share this post


Link to post
Share on other sites

Hey there! I've been using this module on several sites and it's great! I did notice, however, that it didn't seem to compress as much as the comparable plugin for WordPress. After doing some digging, I realized it's because it's set to retain exif data. For small images, this can increase size considerably, up to double (what would normally compress down to 40KB might be ~80KB with exif maintained).

In my site installations, I'm just manually changing line 48 in AutoSmush.module from 

const WEBSERVICE = 'http://api.resmush.it/ws.php?exif=true&img=';

to

const WEBSERVICE = 'http://api.resmush.it/ws.php?img=';

Would it be possible to add this as an option in the plugin?

  • Like 2

Share this post


Link to post
Share on other sites

I usually decide if I want to keep exif or not when the image is prepared for upload. But I see your point. It's possible to add an option, but I'm quite busy these days and then I'm off to a vacation... I'm not sure if this module has a potential now that we have webp?

Share this post


Link to post
Share on other sites
9 hours ago, matjazp said:

I usually decide if I want to keep exif or not when the image is prepared for upload. But I see your point. It's possible to add an option, but I'm quite busy these days and then I'm off to a vacation... I'm not sure if this module has a potential now that we have webp?

Definitely not a big deal - I can just hold onto my slightly modified version of the module, especially if you're not planning to make any updates anytime soon (no need to maintain updatability).

Share this post


Link to post
Share on other sites

@matjazp - I think this is a relatively new thing - I have noticed that the autosmush.txt file is getting a LOT of "Unsupported extension svg" entries. I have an SVG logo in the header of the site, so every page load is triggering this. Just wondering if there could be an easy way to prevent these from being logged? Thanks.

Share this post


Link to post
Share on other sites

Can't look at the source right now, but I don't think there is any customizable way of suppressing other then commenting the line that produces it. I haven't been working on this module lately but are you using experimental feature? I don't think this is the way to go now that we have webp support? 

Share this post


Link to post
Share on other sites
1 minute ago, matjazp said:

Can't look at the source right now, but I don't think there is any customizable way of suppressing other then commenting the line that produces it. I haven't been working on this module lately but are you using experimental feature? I don't think this is the way to go now that we have webp support? 

Yes, I am using the "Optimize on Pageimage->url() [EXPERIMENTAL]" option - it's the only way that makes sense to me to actually use this module because I don't want to resize the original and I don't always do a size() or crop() call on images.

I've commented that log line for now, but I am curious about your thoughts with webp - are you suggesting that if webp is implemented, then there is really no point using this module at all, or just don't use the experimental feature? 

Share this post


Link to post
Share on other sites
1 hour ago, adrian said:

are you suggesting that if webp is implemented, then there is really no point using this module at all

Yes. I think you should go with webp using strategy 3 (using <picture>). Be aware that, based on my testing, webp image is not always smaller so I had to set quality to 80. 

On my sites, I don't use Autosmush because my editors prepare/optimize images before uploading them to PW and I serve them as original, I don't resize/optimize them. I consider myself very lucky in that regard as I know it can't be that easy with other clients.

My opinion on optimizing assets (js/css/images/html) has changed lately. I used to be very pedantic on every byte I could shave off. But now? Do I care much if my css is 30% larger/smaller (in term of download speed)? Not really. Do I care if my image is 500k or 300k? No. We are in 2020. Free WiFi everywhere (at least here in Slovenia) and fast enough. WiFi 6 on the way. LTE/4G everywhere and fast enough (and practically free). 5G on the go. Web servers gzip content. Browsers use cache. What I do hate is javascript slowing down my web browsing experience, making the content reflow, serving me ads. So I browse with no js most of the time. I went off topic, sorry... 

  • Like 2

Share this post


Link to post
Share on other sites

Thanks for your thoughts - I must admit I am a little behind in adopting webp, but it's time to get up to speed for sure. I would love to say that I could get clients to optimize before uploading, but it's just not going to happen for all of them and unfortunately they often upload images in the MBs in size, not KBs, so I definitely need to do compression of some sort. I see some sites where they are displaying thumbnails of images which are well over 1MB and even on my 150 Mbps connection, they still visibly load quite slowly so I think it's still important to consider this. Please also consider that in some countries (especially here in Canada), mobile data is stupidly expensive, so even if it's fast enough, it's eating into valuable monthly bandwidth if you're not on WiFi.

Thanks for the suggestion of going with Strategy 3 for WebP - I am curious about images inserted into an RTE - do you use DOMDocument (or preg_replace) to scan for <img> tags and automatically wrap them in <picture> tags and add the <source srcset> tag or do you have another strategy for this?

Thanks again!

 

 

  • Like 1

Share this post


Link to post
Share on other sites
3 minutes ago, adrian said:

I would love to say that I could get clients to optimize before uploading, but it's just not going to happen for all of them and unfortunately they often upload images in the MBs in size, not KBs, so I definitely need to do compression of some sort.

That's why I said I'm lucky. All my PW sites are "in the house" and my "clients" are my colleagues at work and they do what I say :-)

5 minutes ago, adrian said:

Please also consider that in some countries (especially here in Canada), mobile data is stupidly expensive, so even if it's fast enough, it's eating into valuable monthly bandwidth if you're not on WiFi.

I see. My "customers" are 95% from Slovenia so I don't have to worry about that, luckily.

6 minutes ago, adrian said:

Thanks for the suggestion of going with Strategy 3 for WebP - I am curious about images inserted into an RTE - do you use DOMDocument (or preg_replace) to scan for <img> tags and automatically wrap them in <picture> tags and add the <source srcset> tag or do you have another strategy for this?

I haven't implemented webp on my sites so I didn't think about that because I just recently upgraded to PW that has webp support. On my sites images are rarely inserted into RTE. If this is the case then you may be better of using .htaccess strategy.

  • Like 1

Share this post


Link to post
Share on other sites

I guess the remaining 5% of your "clients" should move to Slovenia to be part of that piece of heaven you have there 🙂 

  • Like 1

Share this post


Link to post
Share on other sites

Ok, so I decided to play around with writing a DOMDocument based approach which hooks into Page::render and replaces all:

 <img src="/site/assets/files/1234/image.png" alt="my image" class="my_image_classes">

 with:

<picture class="my_image_classes">
  <source srcset="/site/assets/files/1234/image.png.webp" type="image/webp">
  <img src="/site/assets/files/1234/image.png" alt="my image" class="my_image_classes">
</picture>

Because it happens on page render, this approach works with images embedded into RTE fields, as well as those added via regular <img> tags in template files. It automatically copies classes from the original <img> tag to the picture tag.

I still don't know whether this is the best approach or not, but so far so good 🙂

  • Like 1

Share this post


Link to post
Share on other sites

Would you mind sharing your code? I'm thinking that maybe a textformatter on RTE field would be better fit in some cases as generally images in header/footer are most likely already optimized? I would also be interested in how it goes in long term, what are the savings with webp comparing to optimized images.

I wasn't testing with <picture> but I used this approach:

$config->hasWebpSupport = (strpos($_SERVER['HTTP_ACCEPT'], 'image/webp') !== false); //this is in /site/config.php

$url = $config->hasWebpSupport ? "webpUrl" : "url";
foreach($page->images as $img) {
    echo "<img src='{$img->$url}'> ";
}

But I think Horst commented that this would kill caching (don't remember exactly...). Also, some browsers don't support webp, but I wouldn't bother too much.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Recently Browsing   0 members

    No registered users viewing this page.

  • Similar Content

    • By joshua
      This module is (yet another) way for implementing a cookie management solution.
      Of course there are several other possibilities:
      - https://processwire.com/talk/topic/22920-klaro-cookie-consent-manager/
      - https://github.com/webmanufaktur/CookieManagementBanner
      - https://github.com/johannesdachsel/cookiemonster
      - https://www.oiljs.org/
      - ... and so on ...
      In this module you can configure which kind of cookie categories you want to manage:

      You can also enable the support for respecting the Do-Not-Track (DNT) header to don't annoy users, who already decided for all their browsing experience.
      Currently there are four possible cookie groups:
      - Necessary (always enabled)
      - Statistics
      - Marketing
      - External Media
      All groups can be renamed, so feel free to use other cookie group names. I just haven't found a way to implement a "repeater like" field as configurable module field ...
      When you want to load specific scripts ( like Google Analytics, Google Maps, ...) only after the user's content to this specific category of cookies, just use the following script syntax:
      <script type="optin" data-type="text/javascript" data-category="statistics" data-src="/path/to/your/statistic/script.js"></script> <script type="optin" data-type="text/javascript" data-category="marketing" data-src="/path/to/your/mareketing/script.js"></script> <script type="optin" data-type="text/javascript" data-category="external_media" data-src="/path/to/your/external-media/script.js"></script> <script type="optin" data-type="text/javascript" data-category="marketing">console.log("Inline scripts are also working!");</script> The type has to be "optin" to get recognized by PrivacyWire, the data-attributes are giving hints, how the script shall be loaded, if the data-category is within the cookie consents of the user. These scripts are loaded asynchronously after the user made the decision.
      If you want to give the users the possibility to change their consent, you can use the following Textformatter:
      [[privacywire-choose-cookies]] It's planned to add also other Textformatters to opt-out of specific cookie groups or delete the whole consent cookie.
      You can also add a custom link to output the banner again with a link / button with following class:
      <a href="#" class="privacywire-show-options">Show Cookie Options</a> <button class="privacywire-show-options">Show Cookie Options</button> This module is still in development, but we already use it on several production websites.
      You find it here: PrivacyWire Git Repo
      Download as .zip
      I would love to hear your feedback 🙂
      CHANGELOG
      0.0.5 Multi-language support included completely (also in TextFormatter). Added possibility to async load other assets (e.g. <img type="optin" data-category="marketing" data-src="https://via.placeholder.com/300x300">) 0.0.4 Added possibility to add an imprint link to the banner 0.0.3 Multi-language support for module config (still in development) 0.0.2 First release 0.0.1 Early development
    • By MoritzLost
      This is a new module that provides a simple solution to clearing all your cache layers at once, and an extensible interface to perform various cache-related actions.
      The simple motivation behind this module was that I was tired of manually clearing caches in several places after deploying a change on a live site. The basic purpose of this module is a simple Clear all caches link in the Setup menu which clears out all caches, no matter where they hide. You can customize what exactly the module does through it's configuration menu:
      Expire or delete all cache entries in the database, or selectively clear caches by namespace ($cache API) Clear the the template render cache. Clear out specific folders inside your site's cache directory (/site/assets/cache) Refresh version strings for static assets to bust client-side browser caches (this requires some setup, see the full documentation for details). This is the basic function of the module. However, you can also add different cache management action through the API and execute them through the module's interface. For this advanced usage, the module provides:
      An interface to see all available cache actions and execute them. A system log and logging output on the module page to see verify what the module is doing. A CacheControlTools class with utility functions to clear out different caches. An API to add cache actions, execute them programmatically and even modify the default action. Permission management, allowing you granular control over which user roles can execute which actions. The complete documentation can be found in the module's README.
      Beta release
      Note that I consider this a Beta release. Since the module is relatively aggressive in deleting some caches, I would advise you to install in on a test environment before using it on a live site.
      Let me know if you're getting any errors, have trouble using the module or if you have suggestions for improvement!
      In particular, can someone let me know if this module causes any problems with the ProCache module? I don't own or use it, so I can't check. As far as I can tell, ProCache uses a folder inside the cache directory to cache static pages, so my module should be able to clear the ProCache site cache as well, I'd appreciate it if someone can test that for me.
      Future plans
      If there is some interest in this, I plan to expand this to a more general cache management solution. I particular, I would like to add additional cache actions. Some ideas that came to mind:
      Warming up the template render cache for publicly accessible pages. Removing all active user sessions. Let me know if you have more suggestions!
      Links
      https://github.com/MoritzLost/ProcessCacheControl ProcessCacheControl in the Module directory

    • By David Karich
      Admin Page Tree Multiple Sorting
      ClassName: ProcessPageListMultipleSorting
      Extend the ordinary sort of children of a template in the admin page tree with multiple properties. For each template, you can define your own rule. Write each template (template-name) in a row, followed by a colon and then the additional field names for sorting.
      Example: All children of the template "blog" to be sorted in descending order according to the date of creation, then descending by modification date, and then by title. Type:
      blog: -created, -modified, title  Installation
      Copy the files for this module to /site/modules/ProcessPageListMultipleSorting/ In admin: Modules > Check for new modules. Install Module "Admin Page Tree Multible Sorting". Alternative in ProcessWire 2.4+
      Login to ProcessWire backend and go to Modules Click tab "New" and enter Module Class Name: "ProcessPageListMultipleSorting" Click "Download and Install"   Compatibility   I have currently tested the module only under PW 2.6+, but think that it works on older versions too. Maybe someone can give a feedback.     Download   PW-Repo: http://modules.processwire.com/modules/process-page-list-multiple-sorting/ GitHub: https://github.com/FlipZoomMedia/Processwire-ProcessPageListMultipleSorting     I hope someone can use the module. Have fun and best regards, David
    • By dimitrios
      Hello,
      this module can publish content of a Processwire page on a Facebook page, triggered by saving the Processwire page.
      To set it up, configure the module with a Facebook app ID, secret and a Page ID. Following is additional configuration on Facebook for developers:
      Minimum Required Facebook App configuration:
      on Settings -> Basics, provide the App Domains, provide the Site URL, on Settings -> Advanced, set the API version (has been tested up to v3.3), add Product: Facebook Login, on Facebook Login -> Settings, set Client OAuth Login: Yes, set Web OAuth Login: Yes, set Enforce HTTPS: Yes, add "https://www.example.com/processwire/page/" to field Valid OAuth Redirect URIs. This module is configurable as follows:
      Templates: posts can take place only for pages with the defined templates. On/Off switch: specify a checkbox field that will not allow the post if checked. Specify a message and/or an image for the post.
      Usage
      edit the desired PW page and save; it will post right after the initial Facebook log in and permission granting. After that, an access token is kept.
       
      Download
      PW module directory: http://modules.processwire.com/modules/auto-fb-post/ Github: https://github.com/kastrind/AutoFbPost   Note: Facebook SDK for PHP is utilized.


×
×
  • Create New...