Product file alias tokens from product display

I'm running into an SEO optimization issue here, because of the "Product display" <-> "Commerce product" logic.

My product display has two taxonomy fields; category and type.
And of course several refenreced products (variations)

To improve SEO I'm using file aliasing for my product images which is a vital boost. And the idea is to have a path like [category]/[type]/[title].[ext]

But as product images are in the Commerce product type, and the taxonomy fields in the Display content type, I obviously don't have access to the display's taxonomy tokens from the product images.
Which means I can't SEO optimize files with Drupal Commerce!!

Unless a hook can be used. But still, the issue would be, how to know which display to load, knowing several displays could point to the same product...
It wouldn't be a problem in my case (yet)
And repeating taxonomy fields for each product is not an option.

This is really frustrating and limitating. Any idea how to solve it?

Posted: Sep 13, 2012


S1L on December 17, 2012

In general I'd suggest not using the title as image filename as this does not always accurately reflect the image and does not make a great user experience for your users pinning Pinterest Pins and for your blind website visitors.
For example a product title can be 'black T-shirt with Drupal logo', while a better filename could be 'girl wearing a black T-shirt with Drupal logo'. And that basically should be in your Alt tag, so using the images Alt tag as the image filename makes much more sense to me.

Now I bet that did not help you with your question, but I hope it helps you with your SEO.

And unfortunately using an images Alt tag as filename is (currently) impossible in Drupal (or at least that I am aware of).
And don't get frustrated, get inspired to change what's not perfect yet :)