Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Picture in-a-box system


yoja

Recommended Posts

Hi,

 

I've created a piece of code to have my articles being put in a box which i specify by giving the image's widht and height.

The code checks takes the longes side and calculates the ratio according to it. If added this piece of code to the html_output tep_image()

 

It only performs the action to the pictures starting with ar, cause my article pictures al start with ar.

 

Maybee more people like it this way and the code can be part of the new version.

 

    if ( ($width) && ($height) ) {

     if ($image_size = @getimagesize($src)) {

    	 $height_full = $image_size[1];

    	 $width_full  = $image_size[0];

    	 

    	 if ($height_full > $width_full) {

       $ratio = $height / $height_full;

       } else {

       $ratio = $width / $width_full;        

    	 }

    	 

    	 // only apply this trick for the images of the articles

    	 if  (substr ($src, 0, 9) == "images/ar")

              {

       $height = $height_full * $ratio;

       $width = $width_full * $ratio;

    	 }

    	 

    	 $image .= ' width="' . $width . '" height="' . $height . '"';

     }

   }

Link to comment
Share on other sites

I don't have a working link yet, everything works local only :-(

The system means that picture's are resiced so that they can fit in a box. If you've got a picture of 200 widht/100height and you've difined the picture to be of size 100 100,

what the system wil do is the following:

it will find that width is the biggest, calculate the ratio as being 0.5 and then multiply the picture sizes with it.

The new widht wil become 100, and the height 50

the picture now fits in the 100x100 box and stil keeps its ratio!

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...