Question: I have a Dynamic Component Template which publishes XML to the Broker database which is then dynamically loaded using the Component Presentation factory.

This Xml contains URLs to Images. I need a thumbnail and a full image to be available. I have managed to use the Image Resizer TBB to produce the thumbnails however, I was hoping that this would add separate package items and binaries that could be referenced, but it seems to overwrite the full size images.

Is there a way I can get both into my Xml and the Package without writing my own custom TBB?

Answer: 
Tridion Content Delivery can store multiple ***variants*** of the same Multimedia Component. Each such variant has an ID that identifies it and the variant with no ID (of in newer versions #def# as its ID) is known as the default variant.

When you reference an image from a DWT, it is automatically added as an item to package when the render engine executes your DWT. This item is then later processed by the default "Publish Binaries in Package" TBB that is part of the Default Finish Actions. The Publish Binaries in Package TBB publishes binaries by calling `AddBinary` on them - you can verify this by looking at the original code for most default TBBs that was published on the Tridion forum [here](https://forum.tridion.com/topic.asp?TOPIC_ID=4653) (login required).

```cs
appliedTemplateUri = new TcmUri(item.Properties[Item.ItemPropertyTemplateUri]);
...
engine.AddBinary(itemUri, appliedTemplateUri, targetStructureGroup, 
                 data, fileName);

```

The `AddBinary` method that is called is defined in the TOM.NET CHM as:

```cs
public abstract string AddBinary(
    TcmUri componentUri,
    TcmUri templateUri,
    TcmUri targetLocation,
    byte[] data,
    string fileName
)

```

* ***componentUri***
The multimedia component this item refers to
* ***templateUri***
The template in whose context this AddBinary call is executed (used as variant id)
* ***targetLocation***
The location to publish the binary to (if null, publish to standard path)
* ***data***
The binary data to publish
* ***fileName***
The filename to publish the file under

So as you can see in that last call to `AddBinary`, the Publish Binaries in Package TBB uses a property (look [here](http://code.google.com/p/tridion-practice/wiki/LogPropertiesOfItemsInPackage) if you've never heard of `Item.Properties`) to determine which variant to publish (and publishes the binary as the default variant if the property is not present).

With all this knowledge in hand, the task becomes quite simple: you have to ensure that there are two binary Items in the package for your MMC, each with a different value of the `Item.ItemPropertyTemplateUri` property. 

The default Image Resizer TBB replaces the binary content of the Item it resizes and does not set this property. So the least code you'll have to write is either a pre-processor TBB that duplicates the item or a post-processor TBB that re-adds the item. In both cases the TBB will have to set the "magic" property too.

Useful links:

* [the original C# source code of the default template building blocks](https://forum.tridion.com/topic.asp?TOPIC_ID=4653)
* [a page describing Item.Properties and how to see what they do in your compound template](http://code.google.com/p/tridion-practice/wiki/LogPropertiesOfItemsInPackage)
* [a recent post on the SDL Tridion forum about the same topic](https://forum.tridion.com/topic.asp?TOPIC_ID=6969) (login required)
Basically all the Image Resizer TBB does is resize the image already in package, so the Default Finish Actions TBBcan publish it (using an AddBinary() call).

So what you require is a slight change in the logic of the Resizer TBB (you need to do something yourself here), so that it does not resize the original item in the package, but publishes a variant of it. Then you have two images available on the delivery side (you can distinguish them by sending the resized image to a different structure group for instance).