1

For consistency and usability purposes, we want to set up a default set of image styles which are clearly understood by our editors. This probably means getting rid of default style names like "medium", "large" etc.

The question is, is this likely to break other third party/contrib code that relies on the Styles module? Might we need to patch these (possibly too much of a headache) or just configure them to use the new styles?

Note: styles seem to be defined and displayed to editors purely by their (sometimes auto-capitalised) machine names, so we can't set a friendly name that differs from this.

Also: Is it even possible to remove existing styles? I can only seem to find ways/hooks to add them.

3

You shouldn't remove the default styles (as mentionned), but you can alter them using hook_image_styles_alter

You can remove the options from selected forms using hook_form_alter (as mentionned).

I tried to find a generic approach and happily found this page.

This is how I applied the info:

function mymodule_form_alter(&$form, &$form_state, $form_id) {

  recursiveRemoval($form, 'thumbnail');
  recursiveRemoval($form, 'medium');
  recursiveRemoval($form, 'large');
  recursiveRemoval($form, 'square_thumbnail');

}

function recursiveRemoval(&$array, $val) {

  if (is_array($array)) {

    foreach($array as $key => &$arrayElement) {

      if(is_array($arrayElement)) {

        recursiveRemoval($arrayElement, $val);

      } else {

        if($arrayElement === $val) {

          unset($array[$key]);

        }

      }
    }
  }

}

N.B.: Use at your own discretion.

2

I don't believe you can delete the default styles and doing so would break modules. The Drupal core module relies on the thumbnail style being present.

If you want to improve the usability for your editors, you could simply hide the style where you normally can select it on editor friendly pages.

  • Thanks - how would you hide styles? Form alters? Also, if you can't delete the existing styles, can you edit them? Standardising a thumbnail size probably wouldn't be too problematic. – Parsingphase Jul 21 '11 at 15:35
  • @Parsingphase Yes you can edit the standard styles. I'm not sure where you want to hide the styles, but form alter is most likely the tool of choice. – googletorp Jul 21 '11 at 15:48

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.