6

I am publishing everything to the Broker database, including images. How do I resolve the images from the Broker database using DD4T?

I found a nice example of resolving images from the filesystem here, but this is not what I am looking for.

5

The next release of DD4T (1.26) includes a new DLL called DD4T.Web written by Quirijn Slings which contains a BinaryDistributionModule class and a BinaryFileManager class that are going to handle both Binaries in the database and on the filesystem.

If you need to do this in a DD4T 1.25 project: here's the relevant portion of the BinaryFileManager class which tries to get a binary from the database:

 // the normal situation (where a binary is still in Tridion and it is present on the file system already and it is up to date) is now covered
 // Let's handle the exception situations. 
 IBinary binary = null;
 try
 {
     BinaryFactory.TryFindBinary(urlPath, out binary);
 }
 catch (BinaryNotFoundException)
 {
     LoggerService.Debug("Binary with url {0} not found", urlPath);
     // binary does not exist in Tridion, it should be removed from the local file system too
     if (File.Exists(physicalPath))
     {
        DeleteFile(physicalPath);
     }
     return false;

  }
  return WriteBinaryToFile(binary, physicalPath, dimensions);

Take a look at the full BinaryFileManager and BinaryDistributionModule classes for more detail.

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.