1

I'm working on a pre-existing Drupal 7 website that has been through several iterations so I'm trying to have a tidy up and remove items which are not required.

I'm currently looking at the Image Styles, of which there are 26 on the site. I'm pretty sure a lot are not used any more, is there any best practise method of making sure they're not used before removing them? My current thinking is either to check every Content Type & View to see if they're used, then do a search in the database & code base to see if they appear in there. Is this the best way? Would it cover all locations they could be being used?

1 Answer 1

2

You have a couple of tasks,

  1. Identify all the image styles
  2. Identify where they're used. You can have multiple node displays, views, display suite, panels, etc.
  3. Check if they're defined in code (features/custom modules)
  4. Remove extra ones that aren't being used

They all apply to images. So your first step if find image fields and where they're used. Drupal has a report for that.

admin/reports/fields

For Views, you can use,

admin/reports/fields/views-fields

For each content type, check all displays see which ones are used,

admin/structure/types/manage/<CONTENT_TYPE>/display
admin/structure/types/manage/<CONTENT_TYPE>/display/teaser
admin/structure/types/manage/<CONTENT_TYPE>/display/<OTHER_DISPLAYS>

Then see if you have Panels or Display Suite. And check those modules to see if they reference other image styles.

After that, you can start looking into your code. This could be tricky. Assuming the contrib modules are in a separate folder,

sites/all/modules/contrib

It's easy,

grep -rn 'image_format_machine_name' sites/all/modules | grep -v 'contrib'

But if everything is thrown together into modules/, contributed, custom, feature modules, you'll have to exclude contributed modules manually. Probably Excel would be your best bet here.

I think basically that should cover the places where they're used.

Not sure if anyone would have any other ideas.

1
  • Thanks, good to know I was on the right track. I'm going to be implementing this 'tidy' up in the next few weeks so will get back to this then.
    – Neil Nand
    Commented Mar 16, 2017 at 11:50

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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