3

We are using the Generator Dynamic Component TBB provided for DD4T Version 2. And is publishing the images with te real size (3200676 bytes).

enter image description here

enter image description here

I want to compress the images, and I've tried the following: A resizer tbb after the Generator Dynamic component tbb. I can see in ntemplate builder that the image now is: 12400 bytes. This is ok, for me.

enter image description here

But, if I publish the component with the image is still big:

enter image description here

How could I solved this problem?

  • Have you checked in the CT after the changes? I mean try publishing after "save & close" CT in Template builder. – Saurabh Gangwar Oct 30 '15 at 14:24
  • yes, of course. Several times – Aroma Oct 30 '15 at 19:33
3

This is because it doesn't work in the same way as most traditional templating, where your images get added to the package and are then published by another TBB, which I guess is what you were expecting when you tried to use the Image Resizer.

DD4T 2's Generate dynamic component TBB (which actually just calls the BaseComponentTemplate) publishes multimedia components using it's BinaryPublisher as it builds the dynamic component for serialisation. This is (partly) because it also includes additional information such as width, height and file size in the serialised data.

In other words, by the time your Image Resizer TBB gets to do it's magic, it's too late... The image has already been published in a previous step.

Usually, in DD4T based solutions, a delivery side image re-sizing system is employed, such as DD4T's own or SDL Web's Contextual Image Delivery, which negates the requirement to republish data if your templates change and consequently require a different sized image. It also helps if you need to serve different sized images for a responsive and/or adaptive website. Based on previous experience I would definitely recommend this approach and, given that the DD4T team does not supply a templated solution for re-sizing, I think it's pretty clear that they would recommend it also.

If you really want to resize your images during publishing, I have previously written extensions to DD4T's templating libraries, which publish re-sized versions of a component's images and "inject" the published URLs as additional metadata on the serialised multimedia components. If you only need to re-size the image once, then I guess you could do something similar but just replace the published URL, width, height and file size etc.

| improve this answer | |

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.