Using MediaMapper to map one image to several variants

Hi!

We are supposed to use MediaMapper but I’m not sure how to use it and if it works for us.

Our Customer has a base product with id V-1234.
Variants ids are named after color and size, for example:
123401201
1234 - model
012 - color
01 - size

So the same color has like 2-7 different sizes.
123401201 (blue, XS)
123401202 (blue, S)
123401203 (blue, M)
etc…

The image uploaded is namned 1234012.jpg, meaning all variant of that color 1234012XX should have that image connected.
Can this be solved with MediaMapper?

Thanks!

/Kristoffer

Litium version: 6.3.1
MediaMapper: 4.0.1

Sorry ProductMediaMapper does not support multi variants mapping. It maps one to one. So you need to have distinct images to distinct variatIds.

Ok, thanks for the Quick response.
Is there any way to hook into/extend the MediaMapper to create your own functionallity?

/Kristoffer

Sorry not extendable but you can create a background job to perform the logic you would like to have on existing images.

Thanks!
I’m thinking of hooking into the file create event using this:

But the event does not get triggered on file upload. Do I need to add something i web.config maybe or should the code be triggered anyway?

If you did as the example and have the “[Autostart]” attribute you don’t need anything extra in web.config.

Ok, thanks. I have it but it still doesn’t trigger but now I know that is all I need to do.

1 Like

Did you restart the IIS?

Just tried it with no luck. I guess it should work Litium 6 as well?

I just tried the same code from the other thread in Litium 6.3.7, and I can hit the break point when the event fires from uploading a new file.

Can you share some code from your implementation?

Strange! I just added this class to my project. It is a 6.3.1 but I guess that is not the issue.

[Autostart]
public class FileCreatedEventHandler : IDisposable
{
    private readonly Litium.Events.ISubscription<Litium.Media.Events.FileCreated> _subscription;

    public FileCreatedEventHandler(EventBroker eventBroker)
    {
        _subscription = eventBroker.Subscribe<Litium.Media.Events.FileCreated>(fileEvent =>
        {
            var newGuid = fileEvent.Item.SystemId; // caught this break point
        });
    }

    public void Dispose()
    {
        _subscription.Dispose();
    }
}

I guess that should be enough?

/Kristoffer

It looks correct, doesn’t it still get hit?

Hmm, all of a sudden it works. Strange, but I’m happy at the moment.
Thanks for the help!

2 Likes

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.