mvanboordt - 2015-01-26

Hi,

I'm using TCPDF in combination with WordPress(WP) to export low resolution(LR) images to high resolution(HR) images in the PDF.

The user saves a HR image. In WP if you save an image there are 4 versions saved.
1. the original hr version
2. Thumbnail (150x150)
3. Medium (360x360)
4. Large (1024x1024)

When a users uses an image he selects on of these versions.
If the image is saved it get's the image size added to the filename.
e.g. image-150x150.jpg

Before export the hr image in the PDF I search all images and replace them with the hr version.
This is a simple str_replace() function in php to select the image size in the filename and replace it with nothing so the original hr image is selected.

With the tcpdf resize function I resize the hr image to the size the user selected and save it at 300 DPI.

This works great. But here is my problem.
All the images are placed on the page and the content is on top of it.
I would like the hr image to replace the lr images on their own place.

I tried to to do this with a preg_replace() function but that doesn't work.
If I use the tcpdf export image function it immediately places the image.
So I tried to put it in a variable to select it later in the preg_replace() function but that only exports a '2'.

Anyhow I hope you understand my problem and can help me.
Here is the complete code I use. Hope it makes sence
http://pastebin.com/tyaV7Rwh

M.