Jump to content

Recommended Posts

Posted

Thank you anyways.

I've tried uploading new images with new names into a new page on a new day with a quality of 10 and still don't see any differences… Seems like this isn't working properly or that i'm doing something wrong.

Hope someone else can help?

Posted

Filetype is JPEG you said?

If you change things for testing purposes, you can add a param "forceNew" => true to an options array to always override previous versions. And if you want check filesize compared to quality settings you can use the suffix setting for a complete check loop like that:

$img = $page->images->first(); // grab you an image (change code to match your setup)
$newWidth = ($img->width == 2500) ? 2499 : 2500;  // set a width value different than the original image size! (is needed for the test only)

$qualities = array(100, 90, 80, 70, 60, 50, 40, 30, 20, 10);
foreach($qualities as $q) {
    $options = array('forceNew'=>true, 'quality'=>$q, 'upscaling'=>true, 'sharpening'=>'soft', 'suffix'=>"quality{$q}");
    $variation = $img->width($newWidth, $options);
    echo "<p>variation: {$variation->name} :: " . filesize($variation->filename) . "</p>";
}

Code is written in browser, if it doesn't work as expected, please check for typos or come back here and tell me.

And if it works, please drop a note about the result. :)

  • Like 5
Posted

Hi Horst,

Nice bit of code! Tried it out and works nicely. 

Don't know what I was doing wrong but this helps quite a bit.

Thanks a lot!

  • Like 1
  • 7 months later...
  • 4 months later...
Posted
On 5/10/2014 at 2:28 PM, horst said:

I have made a module for you (all). :ph34r:

I have had allready a routine that iterates through all pages and clears all imagevariations. But this only can be safely used if you have not used images in RTE's from the same page. If you have done so, those cannot be identified and gets deleted too. :(

So please double check that you do not use Pageimages in your RTE fields before running this module.

To run it you have to install it, go to its configscreen and check the box to run it. Also there is a second box, always checked by default, that let the script run in testmode. In testmode it doesn't delete the variations but list all found pages and the images count. So, if you really want to delte all ImageVariations sitewide, tipp the box to run the script, untipp the box to run it in testmode and press the submit button.

PageimageRemoveVariations.zip

EDIT: better use this enhanced module version from @tpr, with configuration for excluding imagefields:

enhanced version!

Hi @horst - this module is great and I use it regularly. Only problem is that it causes a deprecated constructor notice in PHP7 (class "filo" has a method "filo" rather than "__construct"). Would you mind updating it? And maybe submit it to the modules directory too?

I could update it for my own use but it would be cool to have an "official" version. :)

  • Like 1
Posted (edited)

@Robin S, you should ask @tpr, - he has made the last / enhanced version, if he updates it.

EDIT:

and if tpr cannot further maintain it, it would be fine if you can do!? (I already have enough modules in the directory, that all need to be maintained)

Edited by horst
Posted
On 16/07/2015 at 0:04 AM, tpr said:

Minor fix for a notice right after installing the module (undefined index). Doesn't affect anything.

PageimageRemoveVariations_0.0.3.zip

Hi @tpr - would you mind updating the module to fix the deprecated constructor? Thanks. :)

16 hours ago, Robin S said:

Hi @horst - this module is great and I use it regularly. Only problem is that it causes a deprecated constructor notice in PHP7 (class "filo" has a method "filo" rather than "__construct"). Would you mind updating it? And maybe submit it to the modules directory too?

 

Posted
On 4/10/2016 at 1:41 AM, tpr said:

if it works fine I can upload it to github/modules dir

It works perfectly, thanks!

  • Like 1
  • 3 weeks later...
Posted

The update throws an error here on PW 3.0.39 (a problem with namespace?):

79:     require_once(\ProcessWire\wire('files')->compile(dirname(\ProcessWire\wire("config")->paths->root . 'site/modules/PageimageRemoveVariations/PageimageRemoveVariations.module') . '/PageimageRemoveVariationsConfig.php',array('includes'=>true,'namespace'=>true,'modules'=>false,'skipIfNamespace'=>false)));
80:            $c = new \ProcessWire\PageimageRemoveVariationsConfig();

 

  • 8 years later...
Posted

Hi @tpr (and @horst),

first, thanks for the module. It was a splendid timesaver in several projects (especially with corrupted webp images/files) in the past.

Is this module still maintained? I ask because i get an error (s. below) with latest Version (0.0.4) with PW 3.0.243.

Thx and cheers

Spoiler

 

Aw shucks… Schwerwiegender Fehler: Uncaught TypeError: count(): Argument #1 ($value) must be of type Countable|array, null given in site/modules/PageimageRemoveVariations/PageimageRemoveVariationsConfig.php:148

#0 site/modules/PageimageRemoveVariations/PageimageRemoveVariationsConfig.php (98): PageimageRemoveVariationsConfig->removeAllVariations(false)
#1 site/modules/PageimageRemoveVariations/PageimageRemoveVariationsConfig.php (69): PageimageRemoveVariationsConfig->doTheDishes(false)
#2 site/modules/PageimageRemoveVariations/PageimageRemoveVariations.module (81): PageimageRemoveVariationsConfig->getConfig(Array)
#3 [internal function]: PageimageRemoveVariations::getModuleConfigInputfields(Array)
#4 wire/core/ModulesConfigs.php (613): call_user_func(Array, Array)
#5 wire/core/Modules.php (1744): ModulesConfigs->getModuleConfigInputfields('PageimageRemove...', Object(InputfieldForm))
#6 wire/core/Wire.php (419): Modules->___getModuleConfigInputfields('PageimageRemove...', Object(InputfieldForm))
#7 wire/core/WireHooks.php (968): Wire->_callMethod('___getModuleCon...', Array)
#8 wire/core/Wire.php (484): WireHooks->runHooks(Object(Modules), 'getModuleConfig...', Array)
#9 wire/modules/Process/ProcessModule/ProcessModule.module (1705): Wire->__call('getModuleConfig...', Array)
#10 wire/modules/Process/ProcessModule/ProcessModule.module (1435): ProcessModule->renderEdit('PageimageRemove...', Array)
#11 wire/core/Wire.php (413): ProcessModule->___executeEdit()
#12 wire/core/WireHooks.php (968): Wire->_callMethod('___executeEdit', Array)
#13 wire/core/Wire.php (484): WireHooks->runHooks(Object(ProcessModule), 'executeEdit', Array)
#14 wire/core/ProcessController.php (361): Wire->__call('executeEdit', Array)
#15 wire/core/Wire.php (413): ProcessController->___execute()
#16 wire/core/WireHooks.php (968): Wire->_callMethod('___execute', Array)
#17 wire/core/Wire.php (484): WireHooks->runHooks(Object(ProcessController), 'execute', Array)
#18 wire/core/admin.php (174): Wire->__call('execute', Array)
#19 wire/modules/AdminTheme/AdminThemeUikit/controller.php (15): require('/Users/olafgleb...')
#20 site/templates/admin.php (101): require('/Users/olafgleb...')
#21 wire/core/TemplateFile.php (328): require('/Users/olafgleb...')
#22 wire/core/Wire.php (413): TemplateFile->___render()
#23 wire/core/WireHooks.php (968): Wire->_callMethod('___render', Array)
#24 wire/core/Wire.php (484): WireHooks->runHooks(Object(TemplateFile), 'render', Array)
#25 wire/modules/PageRender.module (581): Wire->__call('render', Array)
#26 wire/core/Wire.php (416): PageRender->___renderPage(Object(HookEvent))
#27 wire/core/WireHooks.php (968): Wire->_callMethod('___renderPage', Array)
#28 wire/core/Wire.php (484): WireHooks->runHooks(Object(PageRender), 'renderPage', Array)
#29 wire/core/WireHooks.php (1094): Wire->__call('renderPage', Array)
#30 wire/core/Wire.php (484): WireHooks->runHooks(Object(Page), 'render', Array)
#31 wire/modules/Process/ProcessPageView.module (184): Wire->__call('render', Array)
#32 wire/modules/Process/ProcessPageView.module (114): ProcessPageView->renderPage(Object(Page), Object(PagesRequest))
#33 wire/core/Wire.php (416): ProcessPageView->___execute(true)
#34 wire/core/WireHooks.php (968): Wire->_callMethod('___execute', Array)
#35 wire/core/Wire.php (484): WireHooks->runHooks(Object(ProcessPageView), 'execute', Array)
#36 index.php (55): Wire->__call('execute', Array)
#37 {main}
thrown (Zeile 148 in site/modules/PageimageRemoveVariations/PageimageRemoveVariationsConfig.php)

Diese Fehlermeldung wurde angezeigt wegen: Sie sind als Superuser angemeldet. Fehler wurde protokolliert.

 

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.
×
×
  • Create New...