MikheevDesign's picture

How to set the hero image to the webp format?

Accepted answer

As you've probably seen, webp support has been added to core (so you should be able to upload webp files directly):

If you're interested in automatic conversion of images to webp format (e.g. in an image style) then we may need to do a little more work in the Image Effects module first. This issue was on hold pending the core support of webp and I haven't gotten back to it yet since the core support was added. The PR here will need some revision based on the implementation of webp in core:

Comments

As you've probably seen, webp support has been added to core (so you should be able to upload webp files directly):

If you're interested in automatic conversion of images to webp format (e.g. in an image style) then we may need to do a little more work in the Image Effects module first. This issue was on hold pending the core support of webp and I haven't gotten back to it yet since the core support was added. The PR here will need some revision based on the implementation of webp in core:

indigoxela's picture

How to set the hero image to the webp format?

If the question is about hero blocks, then there's currently bad news: The hero block isn't aware of the new feature yet. The allowed file extensions are hard-coded to "jpg jpeg png gif".

But getting a solution for that is just a matter of creating an issue in the queue.

(And being a little patient... :-) )

MikheevDesign's picture

I did, just added wepb format to core / modules / layout / includes / block.hero.inc file


/**
   *  Builds the block's configuration form.
   */
  function form(&$form, &$form_state) {
    parent::form($form, $form_state);

    $upload_validators = array(
      'file_validate_extensions' => array('jpg jpeg png gif webp'),
      'file_validate_image_resolution' => array('3200x1600', '1200x300'),
    );
    $upload_description = theme('file_upload_help', array(
      'upload_validators' => $upload_validators,
    ));
MikheevDesign's picture

The funny thing is that it worked for me on version 1.17.1, where it seems like there was no support yet))

MikheevDesign's picture

I wonder if this block is not in the theme, can I somehow influence it through the preprocessor in the theme.? Or just copy the block with your edits to the layouts folder?

indigoxela's picture

I did, just added wepb format to core / modules / layout / includes / block.hero.inc file

@MikheevDesign that's a little hackish and will break with the next core update.

A more robust solution would be to create an issue, so it gets fixed in core. :-) Do you have an account on Github?

If not, would you prefer, if one of us opens the new issue?