Jump to content

thausmann

Members
  • Posts

    33
  • Joined

  • Last visited

Everything posted by thausmann

  1. Okay, issue created: https://github.com/processwire/processwire-issues/issues/1209 As a quick fix I will re-upload my affected non-transparent PNGs with JPGs. Another possible workaround on template level: if($image->width == $width) { $imgUrl = $image->webp->url; } else { $imgUrl = $image->width($width)->webp->url; }
  2. Thanks for your reply! I just tried that and apparently it gives me the same png url filename.1280x0.png. As soon as I go 1 pixel up or down I get a webp URL.
  3. Hey, I'm trying to completely switch over to WebP and noticed some strange behaviour. Let's say I upload a PNG in Processwire of size 1280x800. $page->image->url ➝ correct URL (filename.webp) $page->image->width(800)->url ➝ correct URL (filename.800x0.webp) $page->image->width(1280)->url ➝ wrong URL (filename.1280x0.png), webp file is not generated $page->image->width(1280)->url(false) ➝ correct URL (filename.1280x0.webp) but webp file is not generated So: When I request a size that equals the original file, no WebP conversion is happening (no webp file is created, although a new PNG is generated (...1280x0.png)). When I use url(false), I get the expected URL but still the file is not generated. Also interesting: this issue is only occuring with PNG, not JPG. My Configuration: $config->imageSizerOptions('webpAdd', true); $config->imageSizerOptions('defaultGamma', -1); GD Pageimage::url Hook from here Also tried to output width(1280)->webp->url, it makes no difference I checked that the PNG version is not smaller in filesize (PNG=450KB, WebP (from other tool)=60KB) Tested with Processwire 3.0.148 and 3.0.160 dev I think this post is about the same issue and where I got the url(false) from. Setting 'useSrcUrlOnFail' => false inside $config->webpOptions results in correct output URL (filename.1280x0.webp), but still the file is not generated. So maybe the webp conversion fails? Apparently I see zero webp logs in logs/image-resizer.txt "Don't use resize" seems like a solution here but this is a generic approach in my code, sometimes uploaded images are simply already in the correct size. Any ideas how to fix this and always get dem sweet sweet WebP images? Or did I find a bug? Maybe @horst has an idea what the cause of this phenomenon could be? ?
  4. For anyone like me who's slowly descending into madness wondering why their fields are ignoring the required validation: Make sure to set required=1 before setting the HTML5 required attribute. Otherwise the required flag will reset to 0. Correct order: $field->required = 1; $field->attr('required', true); Using requiredAttr is more fool-safe, here the order does not matter (and it looks nicer): $field->required(true); $field->requiredAttr(true);
  5. A bit late but hey: If you only pass one argument to attr it will retrieve the value. So to set / tick a checkbox try $field->attr("checked", 1). Note that even attr("checked", 0) will set the checked attribute, so simply do nothing to leave it un-checked. If discard is already an InputfieldCheckbox from your template, you can simply do $field = $page->getInputfield('discard'); and it will automatically come with the correct label, value and checked attr from the backend. To also make this work in a "create new" form (when there is no $page yet) you can also get fields via $fields and a NullPage: $f = $fields->get('discard'); $p = $do_we_already_have_a_page ? $page : new NullPage(); $field = $f->getInputfield($p);
×
×
  • Create New...