Skip to content

Instantly share code, notes, and snippets.

@petyagrill
Created March 14, 2019 03:11
Show Gist options
  • Save petyagrill/c7f184e1353792fad6997c563089139b to your computer and use it in GitHub Desktop.
Save petyagrill/c7f184e1353792fad6997c563089139b to your computer and use it in GitHub Desktop.
webp minishop2
<?php
foreach (['upload_files','upload_images'] as $option){
if($setting = $modx->getObject('modSystemSetting',['key'=>$option])){
$extensions = explode(',',$setting->get('value'));
if(!in_array('webp',$extensions)){
$extensions[] = 'webp';
$setting->set('value',implode(',',$extensions));
$setting->save();
}
}
}
$ms2images = 2;
$source = $modx->getObject('modMediaSource',$ms2images);
$props = $source->get('properties');
$props['thumbnailType']['options'][] = ['text'=>'webp','value'=>'webp'];
$props['imageExtensions']['value'] .= ',webp';
$props['allowedFileTypes']['value'] .= ',webp';
$source->set('properties',$props);
$source->save();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment