需要帮助试图找出如何以编程方式删除Drupal 7中的图像样式。
答案 0 :(得分:6)
$image_style = image_style_load('IMAGE_STYLE');
image_style_delete($image_style);
请参阅https://api.drupal.org/api/drupal/modules!image!image.module/function/image_style_delete/7
您可能需要先刷新图像样式缓存,然后才能删除它。你可以用:
来做到这一点image_style_flush($image_style);
有关详细信息,请参阅:
答案 1 :(得分:4)
<?php
// Load the style.
$style = image_style_load('styleName');
// Flush images associated with the style.
image_style_flush($style);
// Delete the style.
image_style_delete($style);
?>
这不适用于默认样式。建议不要删除它们,因为许多Drupal模块都依赖它。
<强>更新强>
如果您修改了默认样式(缩略图,中等,大),则无法删除它们。相反,你可以将它们恢复到原来的设置,就像这样。
<?php
// Load the style.
$style = image_style_load('styleName');
// Flush images associated with the style.
image_style_flush($style);
// Revert the style.
image_default_style_revert($style);
?>