Processwire - Advanced Image Manipulation: Unterschied zwischen den Versionen
(Die Seite wurde neu angelegt: „https://processwire.com/talk/topic/13911-lazy-loading-of-images/ - Bilder beim Einpflegen resizen (nicht erst beim Page Rendern) == Externe Bilder zu Feldern…“) |
|||
| Zeile 10: | Zeile 10: | ||
Note you may need to add a $page->of(false); before the code example above if you are executing it from a template file. ProcessWire delivers pages to templates in an output-ready state where entities are encoded and such (something you wouldn't want when saving a page). So you just have to disable output formatting to put the page in a state where it can be saved, otherwise ProcessWire will throw an error. This isn't usually necessary in other API contexts, outside of template files. | Note you may need to add a $page->of(false); before the code example above if you are executing it from a template file. ProcessWire delivers pages to templates in an output-ready state where entities are encoded and such (something you wouldn't want when saving a page). So you just have to disable output formatting to put the page in a state where it can be saved, otherwise ProcessWire will throw an error. This isn't usually necessary in other API contexts, outside of template files. | ||
| + | |||
| + | == Image Processing vor dem Rendern der Seite auslösen == | ||
| + | Kann nützlich bei Seiten mit vielen Bildern der Seite sein. | ||
| + | |||
| + | https://processwire.com/talk/topic/13911-lazy-loading-of-images/ | ||
Version vom 22. Mai 2017, 09:11 Uhr
https://processwire.com/talk/topic/13911-lazy-loading-of-images/ - Bilder beim Einpflegen resizen (nicht erst beim Page Rendern)
Externe Bilder zu Feldern hinzufügen
https://processwire.com/talk/topic/1501-using-an-external-image-and-resizing-it/
$page->video_image = 'http://domain.com/path/to/file.jpg'; $page->save();
Fügt beim Aufruf ein Bild aus einer externen Quelle hinzu und speichert es im Bildfeld
Once you've got the image in there, you can resize it like in your example. I'm assuming from the non-plural name 'video_image' that you've defined the field to only hold 1 image rather than many. Though the snippet above should work either way.
Note you may need to add a $page->of(false); before the code example above if you are executing it from a template file. ProcessWire delivers pages to templates in an output-ready state where entities are encoded and such (something you wouldn't want when saving a page). So you just have to disable output formatting to put the page in a state where it can be saved, otherwise ProcessWire will throw an error. This isn't usually necessary in other API contexts, outside of template files.
Image Processing vor dem Rendern der Seite auslösen
Kann nützlich bei Seiten mit vielen Bildern der Seite sein.
https://processwire.com/talk/topic/13911-lazy-loading-of-images/