Jump to content
horst

Page Image Manipulator 2

Recommended Posts

Hi, I have uploaded a new version to Github that fully supports PW 2.6+ with its new naming scheme.

The package now ships with two Pim versions, the older one, called Pim, that can be used until PW 2.5 stable, and the new one, Pim2 that should be used with PW 2.6+

So, if you start a new site with PW 2.6+, simply install Pim2 only!

If you have upgraded PW to 2.6 on an existing site with lots of image variations, you

  1. should install Pim2 additionally to the older one, (do not uninstall it yet!)
     
  2. then you should start to change your API calls in your templates like the following explanation

.

here is a code line from the older Pim:

$image = $image->pimLoad($prefix)->watermarkText($txt, 75)->setQuality(80)->pimSave();

.

To start with smooth change from Pim to Pim2, you can change it to this:

// use the old Pim to remove the PimVariations with old naming scheme:
$image->pimLoad($prefix)->removePimVariations();

// in the copied original code line, only change pimLoad to pim2Load, note the number 2 ! in the new start method !
$image = $image->pim2Load($prefix)->watermarkText($txt, 75)->setQuality(80)->pimSave();

.

This way you have some control on which parts the new creation may take effect, e.g. on a small site you can change all API calls at once and drop caches if exists. On bigger sites you may start at one template / page first, and add more changes later.

.

Regardless of this, you can safely let the call to the older removePimVariations() method stay in your code for a while, as they do not interact with the newer one. After a while, when you do not see any of those old filenames in your assets/files folders, you can remove those lines from your code and also uninstall the older Pim.

All other methods than pimLoad / pim2Load are completly identical and can be seen here in the API

Edited by horst
  • Like 8

Share this post


Link to post
Share on other sites

Hello! How is going?
I am confused how to update pim2 from PW (or really anywhere). Currently I got both pim1 and pim2 installed, but only pim1 is shown in ProcessWireUpgrade with the version 2.1 while pim2 is 2.7. Is there a proper way to handle this?

Share this post


Link to post
Share on other sites

Hi.

There are no plans to update Pim2. And if it will be updated, the version number from Pim1 will be bumped up, so that it shows up in the update modules list. (Pim2 is handled as submodule of Pim, Pim1)

  • Like 1

Share this post


Link to post
Share on other sites

To be correct:

Install pim, what installs pim1, go to modules / site, install pim2 and use pim2load().

It needs a rewrite someday for recent PW versions (2.8+ & 3.0+) :)

  • Like 3

Share this post


Link to post
Share on other sites

Hi @horst, I tried out this module today and it's nice, thanks. :)

But the installation process and the PIM1/PIM2 thing was clear as mud to me - I got it worked out in the end but I don't understand why the module is set up that way.

I get the need for different module versions according to which PW version you are running, but couldn't PIM1 and PIM2 be separate modules be in separate GitHub repos and you just install the one you want? Or better - could there just be a single module that checks the PW version number and uses the right code for that version? That way pimLoad() and pimSave() wouldn't have to be renamed and choosing/installing/using the module would be simpler for the user.

  • Like 1

Share this post


Link to post
Share on other sites

@Robin S it was due to an needed upgrade from Pim1 to Pim2 because of changes in the naming conventions for images in PW > 2.6.?.

At this time Pim1 already was installed and used in many sites. When people upgraded their PW version in those sites, they could not / cannot simply change Pim1 with Pim2. There was a manually action in changing API calls in template files needed. This was / is the reason for this weird behave.

For the simply case of first install of the module, I can use a PW version detection of course, but that wasn't the problem. The problem was / is, that in prior PW versions with use of Pim1:

  • i must used the Pim1 as first / only module, to get the people informed about update changes via upgrade-module(s)
  • must ommit an automated change from old naming convention to the new one, because sites possibly would break down if I would raise a need to recreate every image (!)

So, yes, I was and I'am very unhappy with this situation. If someone has a better solution, please tell me.

-------

BTW, with the CroppableImage3 I run into something similar:

Croppable3 isn't recognized by the widely used upgrade-module from Ryan, so people don't get informed about updates of it. I believe, many sites are running a version prior to 0.9.17. Everytime someone updates an older PW version site to a newer version, they run into a bug that was already fixed a year ago in version 0.9.17. People than always report that they just upgraded from x to PW > 3.0.31* (or similar), and the module now wouldn't work anymore. :( But it is already fixed. They all need to do a manual update, but how can I inform them? The updater should do so, but doesn't do. :(

  • Like 1

Share this post


Link to post
Share on other sites

@horst, I can see how that upgrade would be difficult to do gracefully. Will post back if I have any ideas.

Regarding CroppableImage3 and the ProcessWireUpgrade module: I think the reason why the upgrades module doesn't see available updates for CI3 is due to the module class name that is showing in the modules directory. The class name shown is "CroppableImage3" but I'm not sure where that comes from because it isn't actually a class name that is used in the modules (correct me if I'm wrong). Did you enter that manually? Or maybe it comes from the name of the GitHub repo?

When the upgrades module queries the modules directory it is looking for the classnames...

  • FieldtypeCroppableImage3
  • InputfieldCroppableImage3
  • ProcessCroppableImage3

...but it doesn't find a match for any of these, therefore they are left out of the table of upgradable modules.

Maybe it would be best to follow the example of several of the other fieldtype modules, where the primary name of the module would be FieldtypeCroppableImage3 even though it auto-installs two other modules.

 

  • Like 1

Share this post


Link to post
Share on other sites

The reason it wasn't detected was, that no module was in the root directory of the module, but all each of the three modules resides in its own subdirectory.

  • Like 1

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 bernhard
      --- Please use RockFinder3 ---
    • By MoritzLost
      Cacheable Placeholders
      This module allows you to have pieces of dynamic content inside cached output. This aims to solve the common problem of having a mostly cacheable site, but with pieces of dynamic output here and there.  Consider this simple example, where you want to output a custom greeting to the current user:
      <h1>Good morning, <?= ucfirst($user->name) ?></h1> This snippet means you can't use the template cache (at least for logged-in users), because each user has a different name. Even if 99% of your output is static, you can only cache the pieces that you know won't include this personal greeting. A more common example would be CSRF tokens for HTML forms - those need to be unique by definition, so you can't cache the form wholesale.
      This module solves this problem by introducing cacheable placeholders - small placeholder tokens that get replaced during every request. The replacement is done inside a Page::render hook so it runs during every request, even if the response is served from the template cache. So you can use something like this:
      <h1>Good morning, {{{greeting}}}</h1> Replacement tokens are defined with a callback function that produces the appropriate output and added to the module through a simple hook:
      // site/ready.php wire()->addHookAfter('CachePlaceholders::getTokens', function (HookEvent $e) { $tokens = $e->return; $tokens['greeting'] = [ 'callback' => function (array $tokenData) { return ucfirst(wire('user')->name); } ]; $e->return = $tokens; }); Tokens can also include parameters that are parsed and passed to the callback function. There are more fully annotated examples and step-by-step instructions in the README on Github!
      Features
      A simple and fast token parser that calls the appropriate callback and runs automatically. Tokens may include multiple named or positional parameters, as well as multi-value parameters. A manual mode that allows you to replace tokens in custom pieces of cached content (useful if you're using the $cache API). Some built-in tokens for common use-cases: CSRF-Tokens, replacing values from superglobals and producing random hexadecimal strings. The token format is completely customizable, all delimiters can be changed to avoid collisions with existing tag parsers or template languages. Links
      Github Repository & documentation Module directory (pending approval) If you are interested in learning more, the README is very extensive, with more usage examples, code samples and usage instructions!
    • By Craig
      I've been using Fathom Analytics for a while now and on a growing number of sites, so thought it was about time there was a PW module for it.
      WayFathomAnalytics
      WayFathomAnalytics is a group of modules which will allow you to view your Fathom Analytics dashboard in the PW admin panel and (optionally) automatically add and configure the tracking code on front-end pages.
      Links
      GitHub Readme & documentation Download Zip Modules directory Module settings screenshot What is Fathom Analytics?
      Fathom Analytics is a simple, privacy-focused website analytics tool for bloggers and businesses.

      Stop scrolling through pages of reports and collecting gobs of personal data about your visitors, both of which you probably don't need. Fathom is a simple and private website analytics platform that lets you focus on what's important: your business.
      Privacy focused Fast-loading dashboards, all data is on a single screen Easy to get what you need, no training required Unlimited email reports Private or public dashboard sharing Cookie notices not required (it doesn't use cookies or collect personal data) Displays: top content, top referrers, top goals and more
    • By daniels
      This is a lightweight alternative to other newsletter & newsletter-subscription modules.
      You can find the Module in the Modules directory and on Github
      It can subscribe, update, unsubscribe & delete a user in a list in Mailchimp with MailChimp API 3.0. It does not provide any forms or validation, so you can feel free to use your own. To protect your users, it does not save any user data in logs or sends them to an admin.
      This module fits your needs if you...
      ...use Mailchimp as your newsletter / email-automation tool ...want to let users subscribe to your newsletter on your website ...want to use your own form, validation and messages (with or without the wire forms) ...don't want any personal user data saved in any way in your ProcessWire environment (cf. EU data regulation terms) ...like to subscribe, update, unsubscribe or delete users to/from different lists ...like the Mailchimp UI for creating / sending / reviewing email campaigns *I have only tested it with PHP 7.x so far, so use on owners risk
      EDIT:
      Since 0.0.4, instructions and changelog can be found in the README only. You can find it here  🙂
      If you have questions or like to contribute, just post a reply or create an issue or pr on github, thanks!
    • By MoritzLost
      Sorry for the convoluted title. I have a problem with Process modules that define a custom page using the page key through getModuleInfo (as demonstrated in this excellent tutorial by @bernhard). Those pages are created automatically when the module is installed. The problem is that the title of the page only gets set in the current language. That's not a problem if the current language (language of the superuser who is installing the module) is the default language; if it isn't, the Process page is missing a title in the default language. This has the very awkward effect that a user using the backend in the default language (or any other language) will see an empty entry in the setup menu:

      This screenshot comes from my Cache Control module which includes a Process page. Now I realize the description sounds obscure, but for us it's a common setup: We a multiple bilingual sites where the default language is German and the second language is English. While the clients use the CMS in German, as a developer I prefer the English interface, so whenever I install a Process module I get this problem.
      As a module author, is there a way to handle this situation? I guess it would be possible to use post-installation hooks or create the pages manually, but I very much prefer the declarative approach. The page title is already translatable (through the __ function), but of course at the time of installation there is no translation, and as far as I'm aware it's not possible to ship translations with a module so they are used automatically. Could this situation be handled better in the core? I would prefer if the module installation process would always set the title of the Process page in the default language, instead of the language of the current user.
×
×
  • Create New...