KNOWLEDGE BASE
Log In    |    Knowledge Base    |    4D Home
Tech Tip: Using the CREATE THUMBNAIL Command
PRODUCT: 4D | VERSION: 6.7 | PLATFORM: Mac & Win
Published On: March 2, 2001

When you want to publish pictures on the Web using 4D and control their size, you can define it in the image source tag as follows:

<img src="/4DACTION/MyMethod/<!--4DVAR [Paragraphs]Subtitle-->width='48' height='48'">

In this example, the image is sent to the browser through the MyMethod method:



This method queries the database using the field [Paragraphs]Subtitle and sends the equivalent picture through the SEND HTML BLOB command. Although this works, there are cases when you do not want the original picture to be sent. If a picture is too big and needs to be scaled down by the browser, sending the actual picture will waste both the bandwidth and the browser's RAM. This is where the CREATE THUMBNAIL command comes into play.

Using that command you can create a thumbnail with the size attributes that you wanted to assign to the image. Once the thumbnail is created, you just need to send it using the SEND HTML BLOB command, as you would have sent the original picture.

The tag would then become:



and the method would be modified accordingly:


By using this method, you make sure that the browser only downloads what it needs and that the use of the browser's RAM is optimized.


To copy the code described above, select the text below:

C_BLOB($MyBlob)
$1:=Replace string($1;"/";"")
QUERY([Paragraphs];[Paragraphs]Subtitle=$1)
PICTURE TO BLOB([Paragraphs]Field5;$MyBlob;"JPEG")
SEND HTML BLOB($MyBlob;".jpeg")
C_BLOB($MyBlob)
$1:=Replace string($1;"/";"")
QUERY([Paragraphs];[Paragraphs]Subtitle=$1)
CREATE THUMBNAIL([Paragraphs]Field5;$MyPicture)
PICTURE TO BLOB($MyPicture;$MyBlob;"JPEG")
SEND HTML BLOB($MyBlob;".jpeg")