Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Problem/Motivation
Allow users to upload and manage images of Google's image format, WebP (https://developers.google.com/speed/webp)
Steps to reproduce
- Add webp as allowed extension
- Allow to use Image GD Toolkit's imagecreatefromwebp() function
Proposed resolution
Remaining tasks
None.
User interface changes
Nothing.
API changes
Nothing.
Data model changes
Release notes snippet
Allow users to use images with .webp extension.
Comment | File | Size | Author |
---|---|---|---|
#6 | Image appearance.png | 168.46 KB | mitthukumawat |
#6 | Image extension in content type.png | 61.67 KB | mitthukumawat |
#6 | Image upload.png | 84.47 KB | mitthukumawat |
#2 | add_webp_support_for_core_image_module-3179554-1.patch | 1.48 KB | danyg |
Comments
Comment #2
danyg CreditAttribution: danyg at Cheppers commentedHere is my patch which allows the users to use webp extension for image upload fields and works with built-in image styles.
Comment #3
VasyOK CreditAttribution: VasyOK commentedThank you danyg! Patch worked. But after after node save i see:
PDOException: SQLSTATE[HY000]: General error: 1366 Incorrect integer value: '' for column 'field_slideimage_width' at row 1: INSERT INTO {field_data_field_slideimage} (entity_type, entity_id, revision_id, bundle, delta, language, field_slideimage_fid, field_slideimage_alt, field_slideimage_title, field_slideimage_width, field_slideimage_height) VALUES (:db_insert_placeholder_0, :db_insert_placeholder_1, :db_insert_placeholder_2, :db_insert_placeholder_3, :db_insert_placeholder_4, :db_insert_placeholder_5, :db_insert_placeholder_6, :db_insert_placeholder_7, :db_insert_placeholder_8, :db_insert_placeholder_9, :db_insert_placeholder_10); Array ( [:db_insert_placeholder_0] => node [:db_insert_placeholder_1] => 24 [:db_insert_placeholder_2] => 24 [:db_insert_placeholder_3] => slide [:db_insert_placeholder_4] => 0 [:db_insert_placeholder_5] => und [:db_insert_placeholder_6] => 36 [:db_insert_placeholder_7] => [:db_insert_placeholder_8] => [:db_insert_placeholder_9] => [:db_insert_placeholder_10] => ) в функции field_sql_storage_field_storage_write() (строка 610 в файле /home/u8615/domains/moybuhgalter.com.ua/modules/field/modules/field_sql_storage/field_sql_storage.module).
Comment #4
danyg CreditAttribution: danyg at Cheppers commented@VasyOK The WebP support of getimagesize() function was implemented in PHP 7.1.0
In older PHP versions getimagesize() cannot recognize the webp filetypes (This is what I just discovered last week).
Can you confirm that the PHP version is older in your site? If not, we should figure out what's wrong.
Comment #5
VasyOK CreditAttribution: VasyOK commentedtoday php 5.6
ok i try to update php version
thanx, danyg!
Comment #6
mitthukumawat CreditAttribution: mitthukumawat as a volunteer and at Zyxware Technologies for Drupal Association commentedI have applied the patch #2 in drupal 7.80 and checked the support of webp images.
Testing steps:
Adding after patch screenshots for reference.
Comment #7
mitthukumawat CreditAttribution: mitthukumawat as a volunteer and at Zyxware Technologies for Drupal Association commentedComment #8
poker10 CreditAttribution: poker10 at ActivIT s.r.o. commentedPatch looks good. Adding a related issue as if that backport gets commited with any luck, then we should be able implement more generic solution, instead of this hardcoded one (such as the one currently present in D8/9).
Until that this patch works for us on PHP 7.1+
Comment #9
poker10 CreditAttribution: poker10 at ActivIT s.r.o. commentedComment #10
mgiffordComment #11
poker10 CreditAttribution: poker10 at ActivIT s.r.o. commentedLet's postpone this for #2539478: [D7] Allow image fields to use any extensions the current image toolkit supports (instead of hard-coding jpg, png and gif only) to aim for a generic solution (not the hardcoded one).
Comment #12
mgiffordI don't know why we're trying to add this to D7 at this point. Bumping it up to D10. Hopefully we don't have to wait till 11.
AVIF & WebP are already ready to roll:
https://caniuse.com/?search=avif
https://caniuse.com/?search=webp
Comment #13
poker10 CreditAttribution: poker10 at ActivIT s.r.o. commentedAs far as I know, D10 currently supports WebP without the need of any additional module, so this is only a D7 issue. The original issue is here: #2340699: Let GDToolkit support WEBP image format
D10/11 Avif issue is here: #3202016: Let GDToolkit support AVIF image format.
I agree that it is possible, that this would not move anywhere until the EOL, but let's keep the relevant issues open until then. Thanks!