Jump to content

gonzz

Members
  • Posts

    7
  • Joined

  • Last visited

Everything posted by gonzz

  1. Thanks @adrian for the links. I have carefully read ProcessCustomUploadNames.module and put this together. Here's a gist with the module I wrote: https://gist.github.com/gonzam88/2b0e8f850c469b48f4ea50fec29a4b1f It's working for me but can't guarantee anything. Anyone is free to grab this code and continue developing into a full featured module. Thanks for everyone's input
  2. Hi @adrian thanks for the heads up. I do have a couple of checks so it's not fired on every save, but i'm not handling the situation where the TIFF is replaced ? My first attempt was using InputfieldFile::fileAdded but I wasn't sure how to get the uploaded file data and the page instance. Tried I couple of things googling around but nothing worked for me. Any working example to point me?
  3. Thanks everyone for your responses, got me on track. I ended up making a module that hooks after saveReady. After some validation it does the following. Hope it helps anyone. This could be transformed into a more advanced module with options. Server needs Image Magick module installed. // Lets generate a png image from this tiff // imagen_tiff is a file field $tiffImgPath = $page->imagen_tiff->first()->filename; $tiffImgName = preg_replace('/\\.[^.\\s]{3,4}$/', '', $page->imagen_tiff->first()->name); // Create an Imagick from the TIFF $maxWidth = 1024; $maxHeight = 768; $img = new Imagick($tiffImgPath); // Size calc $d = $img->getImageGeometry(); $w = min($d['width'], $maxWidth); $h = min($d['height'], $maxHeight); // Convert image to PNG $img->setImageFormat('png'); $img->setCompressionQuality(97); $img->setImageResolution(72, 72); $img->resizeImage($w,$h, Imagick::FILTER_LANCZOS, 1, true); // Save the converted image to a cache folder $tempDir = wire()->files->tempDir('tiffpng')->get() . $tiffImgName .'.png'; $img->writeImage($tempDir); // I save the cached image in the image field imagen_web $page->imagen_web->add($tempDir);
  4. thanks @elabx for the reply. Time is not an issue, and this is a core feature for the website. It's also key that this is easy to use, without the need to previously convert the file to png. Client is not computer savvy. Thanks for pointing me to the s3 module. I should create the png with imagemagick, inside the ___fileAdded function (line 63) right? ..Can i create an image object on the fly? Or should I set an image field (maybe hidden) and set that in the ___fileAdded function? Please let me know if i'm not clear ? thanks
  5. I'm doing an artist site and they want to be able to upload a large .tiff to their portfolio. I need to keep to a copy of the original file in the server for the art distributers, and of course serve jpg in the web front end. I had the idea of extending the file or image upload input so that if the image is tiff, keep it, and also convert it to jpg, so I could access through something like $image->originalUrl or $image->size(100, 100)->url I was wondering if you thought this a good idea, or if i'm over-engineering something that could be done simply. Also, I've never extended an input, so any examples are welcome. Thanks!
  6. Thanks @adrian You made me realize I had code executing on ready.php which was embedding css in the admin page, hence the unexpected < Others postings led me to think it was a system problem, rather than my own code.
  7. Hi i'm having a recurrent problem I found on this forum: when using the image uploader I get the following error on console "Unexpected token < in JSON". But I couldn't solve it with any of the other proposed solutions: setting debug to true setting $config->uploadTmpDir = dirname(__FILE__) . '/assets/uploads/'; setting uploadTmpDir in php.ini BUT This problem only appears for non superuser users (ie editors). Running on a Digitial Ocean Server with NGINX and PHP 7.1. Version is ProcessWire 3.0.62 Note: Im using Fredi plugin, but i doubt that's the problem because I'm using it in other sites with no problem Any idea how i could solve this (even with non ajax image upload) I need to sort this as fast and simple as possible Thanks in advance
×
×
  • Create New...