Jump to content

matjazp

Members
  • Posts

    687
  • Joined

  • Last visited

  • Days Won

    4

Everything posted by matjazp

  1. Just before commit to GH I added /*NoCompile*/ option introduced in lasted PW dev and somehow added dot, don't know why I hope I didn't break other things... It's working fine on windows with php 7.1, tried on linux with php 7.0 and got an error. I just pushed a fix for that. Thx for reporting. Optimizers on linux: I can't make instructions on how to install them, since there are so many flavors of *x, but it looks like apt-get is now some sort of standard.
  2. I made some changes in v1.0.4 (just uploaded to GH). At the bottom at the module config you can see what is the path being search for local optimizers (executables) and which optimizers have been found. If optimizer is not found, then it's skipped. I extended the search path so you can put optipng, jpegoptim and gifsicle on the root of PW ($config->paths->root) on templates directory ($config->paths->templates) and assets directory ($config->paths->assets). If you have shell access then you can install all three mentioned optimizers with apt-get install optipng jpegoptim gifsicle Hope that helps.
  3. Hi, sorry for the late reply. I'm using OptimizerFactory library and that's how it works. Quick workaround would be changing the source code in the library, so that only one optimizer would run. Open /site/modules/AutoSmush/image-optimizer/src/ImageOptimizer/OptimizerFactory.php and change to this: $this->optimizers['png'] = new ChainOptimizer(array( $this->optimizers['optipng'], //reversed the order so optipng is first $this->optimizers['pngquant'], $this->optimizers['pngcrush'], $this->optimizers['advpng'] //)); ), true); //if true, just first optimizer will run, if false all optimizers will run I'll see what I can do, since others that are using this library has similar problems. Author of the library does not response to this issue, but we will find a solution. It might take some time though.
  4. It's meant to be, but it's not. Take this one: https://github.com/matjazpotocnik/DynamicRoles Edit on 3. Jan 2018: updated my version of droles with fixes for GH issues 14 and 16.
  5. jpegoptim_bin is just for jpegoptim, the other options are: optipng_bin pngquant_bin pngcrush_bin pngout_bin gifsicle_bin jpegtran_bin Would it help if you could enter the paths in the module settings page?
  6. It looks like executable is not found because it's not within the PATH. Do php -r "print getenv('PATH');" from shell or phpinfo(); from php and check for environment variable PATH. Make sure that jpegoptim (and others) are on the path. You could also check what shell is executed: echo shell_exec("echo $0"); It's possible that it's sh and not bash You may need to use the putenv command or determine whether your path needs to be set in /etc/profile, ~/.profile or ~/.bashrc in order for it to be picked up by the user runing php. Some versions of apache read configuration from /etc/apache2/envvars . You can set environment vars locally within a VirtualHost config using SetEnv. Or it might help if you put putenv('PATH=/your/path'); somewhere in the php, just for the test. You could also set the path of jpegoptim (and other binaries) by modifying optimizeSettings in AutoSmush.module: $this->optimizeSettings = array( 'ignore_errors' => false, //in production could be set to true 'jpegtran_options' => array('-optimize', '-progressive', '-copy', ' all'), 'jpegoptim_options' => array('--preserve', '--all-progressive', '--strip-none', '-T' . self::JPG_QUALITY_THRESHOLD), 'optipng_options' => array('-i0', '-o2', '-quiet', '-preserve'), 'advpng_options' => array('-z', '-3', '-q'), 'jpegoptim_bin' => '/path/to/jpegoptim', <== add this line ); All this is specific to the environment, so I can't give detail instructions on how to make "Local tools" to work. I'm also not a linux user, I tested tools on windows. Let me know how it goes.
  7. Oh! End $event->arguments[0] being the current rendered file ... Cute Thx for the hint!
  8. I'm after InputfieldFile::renderItem where $event->return is markup. I've updated the function so it works for Pageimage and Pagefile: /** * Returns Pageimage or Pagefile object from file path * getPageimageOrPagefileFromPath('/site/assets/files/1234/file.jpg'); // returns either Pageimage or Pagefile object * getPageimageOrPagefileFromPath('/site/assets/files/1234/file.txt'); // returns Pagefile object * getPageimageOrPagefileFromPath('/site/assets/files/1234/none.txt'); // returns null * * @param straing $filename full path to the file eg. /site/assets/files/1234/file.jpg * @param Page|null $page if null, page will be contructed based on id present in the file path * @return Pagefile|Pageimage|null * */ function getPageimageOrPagefileFromPath($filename, $page = null) { if(is_null($page)) { $id = (int) explode('/', str_replace(wire('config')->urls->files, '', $filename))[0]; $page = wire('pages')->get($id); } if(!$page->id) return null; // throw new WireException('Invalid page id'); $basename = basename($filename); // get file field types, that includes image file type $field = new Field(); $field->type = wire('modules')->get('FieldtypeFile'); $fieldtypes = $field->type->getCompatibleFieldtypes($field)->getItems(); $selector = 'type=' . implode('|', array_keys($fieldtypes)); //foreach(wire('fields')->find($selector) as $field) { foreach($page->fields->find($selector) as $field) { $files = $page->getUnformatted($field->name); if($files) { $file = $files[$basename]; if($file) return $file; // match found, return Pagefile or Pageimage //check for image variations foreach($files as $file) { //if(method_exists($file, "getVariations")) { if($file instanceof Pageimage) { $variation = $file->getVariations()->get($basename); if($variation) return $variation; // match found, return Pageimage } } } } return null; // no match }
  9. function getPageimage ($filename) { $f = str_replace(wire('config')->urls->files, '', $filename); $id = explode("/", $f)[0]; // get image field types $img = new Field(); $img->type = wire("modules")->get("FieldtypeImage"); $fieldtypes = $img->type->getCompatibleFieldtypes($img)->getItems(); unset($fieldtypes["FieldtypeFile"]); $selector = "type=" . implode("|", array_keys($fieldtypes)); foreach (wire('fields')->find($selector) as $field) { foreach (wire('pages')->find("$field>0, include=all") as $page) { $images = $page->getUnformatted($field->name); $pageimage = $images[basename($filename)]; // check should be performed that this image actually reside on the right page if($pageimage !== false) { if($page->id == $id) return $pageimage; // we have a match } } return null; // no match } var_dump(getPageimage('/site/assets/files/1087/img18.jpg')); // Pageimage object var_dump(getPageimage('/site/assets/files/1087/nonexistant.jpg')); // null EDIT: I should grab id from filename and search for image fields on that page only... I could also find image fieldtypes on the page itself...
  10. Yes, you would need a field and a page and I don't have that ...
  11. Nope, tried that before, page object need to be saved first.. Not this time, I'm in hook, but with markup only. I just believed that a function/method like $myfileobject = WiregetPagefile('/site/assets/files/1234/myfile.txt'); or $myfileobject = $page->getPagefile('/site/assets/files/1234/myfile.txt'); exist somewhere in the core or in core module.
  12. Thanx Robin (and Lostkobrakai) for you answers. It would work, but then I would need existing page. Ok, this was just an idea on how to crate fake Pagefile Let's try this more realistic approach: how to get Pagefile object if I don't know the field name file is attached to? I have page id so I could do $p=$pages->get($id); Now I would need to iterate through Pagefile fields on that page and on each field check if myfile matches. I was hoping for more elegant solution...
  13. I don't have $my_files_field. I know that Pagefiles are "connected" to the page that has FieldtypeFile, but I actually don't want to add a file to the page, I just want to create a Pagefile object, that has basename, filename, ext, size, url, httpUrl etc. methods/properties.
  14. How to create Pagefile or Pageimage knowing only file url, like /site/assets/files/1234/file.txt
  15. Module: Auto Smush PDF https://github.com/matjazpotocnik/AutoSmushPDF Compress PDF files automatically on upload, manually by clicking the link for each file and in bulk mode for all PDF files. In Automatic mode PDF files that are uploaded are automatically compressed. In Manual mode "Compress" link will be present. This allows manual compression of the individual PDF file. In Bulk mode all PDF files can be compressed in one click. Will process PDF files sitewide, use with caution! Using https://labstack.com/, free (at the moment) online web service that provides compressing of PDF files. There is no limit in file size and no limit on number of uploaded PDF's. No privacy policy available. EDIT April 30 2017: This module is not working anymore as Labstack removed support for pdf compression.
  16. Sorry for inconvenience! I just realised that the whole directory was missing on github. I fixed that and also upgraded AS to v1.0.2 that add support for CroppableImage3.
  17. It's not working, if the module has it's own install method. I added that in v1.6.1 to check for mbstring and iconv support. To overcome this you have to either remove your own install method or create a page by yourself, like this: public function ___install() { /* try { $this->installPage('file-editor', 'setup', 'Files Editor'); } catch(Exception $e) { $this->error("Can't create a page."); } */ parent::___install(); if(!extension_loaded('mbstring') || !function_exists('iconv')) { $this->message("Support for mbstring and iconv is recommended."); } } Thank you both for the report, v1.6.4 is up & running Edit: I forgot to call parent::___install();
  18. Hi, adrian! I added a warning to the readme file for next versions, so that everyone should be aware that they need a backup solution in case they cut himself off the admin. I'm not creating the page by myself, I'm letting PW do it for me: $info = array( 'title' => 'Files Editor', 'summary' => _('Edit files'), 'version' => '1.6.3', 'author' => 'Florea Banus George, Matjaž Potočnik, Roland Toth', 'icon' => 'file-o', 'href' => 'https://github.com/matjazpotocnik/ProcessFileEdit/', 'requires' => 'ProcessWire>=2.5.5, PHP>=5.3.8', 'permission' => 'file-editor', 'permissions' => array( 'file-editor' => _('Edit Files (recommended for superuser only)') ), 'page' => array( 'name' => 'file-editor', 'parent' => 'setup', 'title' => 'Files Editor' ), ); @adrian,would you be so kind and PM me, I would appreciate if you could give me more info about your server.
  19. It's not compatible with CI3, but I think I know why and I think I know how to fix it Will report, stay tuned.
  20. I don't know about plans. The service is up for quite a time, sure more over a year, but it's not clear who is owner of site. Site is created by French Tech, the collective name for all those working in the French startup market. There is also no privacy policy available, so who knows what happen with your uploaded images. There are other services with "free" plans, but with limitations, like file size (100kB) or number of images (eg. 500 per month). I actually don't like web services, because first you upload the image to your server, then upload to web service and then download it. That's why I use local tools on the server, but that come with a price, cpu & memory usage, but I can aford it, since I'm the sysdamin Auto Smush is somehow different from other modules, since it does not add the method(s) to PageImage, thus you don't have to change your code and also you may uninstall (or disable) the module at any time without code modification in your templates.
  21. Module: Auto Smush https://github.com/matjazpotocnik/AutoSmush Optimize/compress images. In Automatic mode images that are uploaded can be automatically optimized. Variations of images that are created on resize/crop and admin thumbnails can also be automatically optimized. In Manual mode "Optimize image" link/button will be present. This allows manual optimization of the individual image or variation. In Bulk mode all images, all variations or both can be optimized in one click. Will process images sitewide. Two optimization "engines" are avaialable. reShmush.it is a free (at the moment) tool that provides an online way to optimize images. This tool is based on several well-known algorithms such as pngquant, jpegoptim, optipng. Image is uploaded to the reSmush.it web server, then optimized image is downloaded. There is a 5 MB file upload limit and no limit on number of uploaded images. "Local tools" is set of executables on the server for optimizing images: optipng, pngquant, pngcrush, pngout, advpng, gifsicle, jpegoptim, jpegtran. Binaries for Windows are provided with this module in windows_binaries folder, copy them somewhere on the PATH environment variable eg. to C:\Windows. Similar modules: JpegOptimImage by Jonathan Dart: https://processwire.com/talk/topic/6667-jpegoptimimage/ TinyPNG Image Compression by Roope: https://github.com/BlowbackDesign/TinyPNG ProcessImageMinimize by conclurer: https://processwire.com/talk/topic/5404-processimageminimize-image-compression-service-commercial/ Forum discusion: https://processwire.com/talk/topic/12111-crowdfunded-tinypng-integration-module/ Module created by Roland Toth (@tpr).
  22. v1.5.0: - warning about unsaved changes (suggested by tpr) - better wording about include/exclude filter (suggested by tpr) - better visual feedback on Save (suggested by tpr) - theme selection (suggested by tpr) - small speed improvement on directory tree generation - small enhancements and fixes - codemirror update to 5.20.2 Thanks to our "Man on Steroids"
  23. Thx, kixe. I wrongly expected that wireClassExists('bar') would always return true, with or without namespace. Because this is not the case, this is why DynamicRoles module (and possible others?) doesn't work on PW3 unless you add namespace.
  24. <?php // in mytemplate.php echo "Roles:" . wireClassExists('Roles') . "<br>"; // expecting true echo "foo:" . wireClassExists('foo') ."<br>"; // expecting false class bar extends Roles { } echo "bar: " . wireClassExists('bar') ."<br>"; //expecting true Output: Roles:1 foo: bar: If I add namespace ProcessWire in mytemplate.php, then the result is as expected, class bar exists: <?php namespace ProcessWire; // in mytemplate.php echo "Roles:" . wireClassExists('Roles') . "<br>"; // expecting true echo "foo:" . wireClassExists('foo') ."<br>"; // expecting false class bar extends Roles { } echo "bar: " . wireClassExists('bar') ."<br>"; //expecting true Output: Roles:1 foo: bar: 1 This is how it should be?
×
×
  • Create New...