Site icon Osclass Documentation & Knowledge Base

Improve image upload: fixes thumbnails that are too small

One issue with the way Osclass currently uploads images is that thumbnail images may appear too small, with excess white space around them. This issue is most noticeable when uploading smaller images.

Example:

Here is the original full-size image:

This is the thumbnail image that is generated. Notice how small the actual image appears.


After the fix as outlined below, you can expect a thumbnail like this:

What causes this issue?

This issue stems from the way Osclass processes the original uploaded image, which is used to create three subsequent images(sizes shown are default):

To create the normal image, the original uploaded image is reduced in size and overlaid onto a new “blank” white image that is 640×480. If the original image is smaller than this size, the image is simply overlaid as-is, centered. This can leave excess white space around the image. If watermarks are enabled, the watermark is applied at this point to the normal image.

The preview image is then created directly from the normal image. Finally, the thumbnail image is generated from the preview image.

Here’s a visualization of the process:

The fix:

To fix this, each of the 3 image sizes should be created individually from the original image, rather than being created from re-sized versions of the normal image. This is a very easy change to make:Edit file ItemActions.php located in /oc-includes/osclass/.On lines 1286 and 1291, change:

$normal_path

to

$tmpName

That’s it! Note: the specific line numbers may change, but they’ll be “around” those lines.

Important Notes: