Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Putting a Border on Images


cpruissen

Recommended Posts

Posted

Hi,

 

Many of my images are of business forms that could really us a border around them to make them stand out. Any ideas how I can do this. Everything is working on my oscommerce program and after all the work getting it to the point of setting it live very soon, I'm too afraid to go in an muck with any of the code without knowing what to do first....lol

 

Thanks as always for the help.

 

Catherine

childcare.net

Posted

check the function in includes/functions_html_output.php

 

// The HTML image wrapper function

 function tep_image($src, $alt = '', $width = '', $height = '', $parameters = '') {

   if ( (($src == '') || ($src == DIR_WS_IMAGES)) && (IMAGE_REQUIRED == 'false') ) {

     return false;

   }

 

to put a border to ALL your images that use the tep_image function (and thats about everything

 

// The HTML image wrapper function

 function tep_image($src, $alt = '', $width = '', $height = '', border='1', $parameters = '') {

   if ( (($src == '') || ($src == DIR_WS_IMAGES)) && (IMAGE_REQUIRED == 'false') ) {

     return false;

   }

 

I haven't tested it but that's a possibility

Robert

 

We all need to learn it once, how hard it may seem when you look at it, also you will master it someday ;)

Posted

That would put a border round things such as the rounded corners and the one pixel gifs as well as the cartoon images.

Posted

Here is the solution to the borders on only product images.

 

* * BACK UP YOUR FILES FIRST * *

 

You will need to make this change in catalog/includes/functions/htmloutput.php

 

Here is the first part:

 

 

// The HTML image wrapper function 

 function tep_image($src, $alt = '', $width = '', $height = '', $parameters = '') { 

   if ( (($src == '') || ($src == DIR_WS_IMAGES)) && (IMAGE_REQUIRED == 'false') ) { 

     return false; 

   } 

// Zebra001 added 

  $borderforimage = 'false'; 

  if (($width == SMALL_IMAGE_WIDTH) && ($height == SMALL_IMAGE_HEIGHT))     $borderforimage = 'true'; 

//end Zebra001 added 



// alt is added to the img tag even if it is null to prevent browsers from outputting 

// the image filename as default 



   $image = '<img src="' . $src . '" border="0" alt="' . htmlspecialchars($alt) . '"'; 



   if (tep_not_null($alt)) { 

    $image .= ' title=" ' . htmlspecialchars($alt) . ' "'; 



// Zebra001 added 

   if  ($borderforimage == 'true')    $image .=  ' class=fotgal '; 

// end Zebra001 added 

   

}

 

 

Second Step:

 

Edit/Add to stylesheet.css

 

.fotgal {border:2px; border-thickness: 2px; border-color: #ffffff; 

border-style: solid;} 



A:hover .fotgal, A:active .fotgal {border:2px; border-thickness: 2px; 

border-color: purple; border-style: solid}

 

Put second step in the main stylesheet.css

 

The css with a white border which trurns purple when you hover over it (Make appropriate changes).

The other message contained the changes to htmloutput.php

 

Let me know how this goes.

 

-J

Posted

speechless...

 

haven't tried it but what i read in the code is a very smart solution !

 

2 thumbs up

Robert

 

We all need to learn it once, how hard it may seem when you look at it, also you will master it someday ;)

Posted

Hi Jeff,

 

Thanks so much for taking the time to help me with this. I sure hope it workd. Right now I am getting a parse error in the html_output from the code you provided, and, being the non-expert I am, I'm hoping you can spot the problem for me. I've tried all different things but to no avail.

 

I look forward to your response.

 

Catherine

Posted

Hi Jeff,

 

Boy, a little sleep does wonders for the eyesight. I found the problem with the parse errors. A couple of closing } were missing.

 

re:

// The HTML image wrapper function

function tep_image($src, $alt = '', $width = '', $height = '', $parameters = '') {

if ( (($src == '') || ($src == DIR_WS_IMAGES)) && (IMAGE_REQUIRED == 'false') ) {

return false;

}

}

// Zebra001 added

$borderforimage = 'false';

if (($width == SMALL_IMAGE_WIDTH) && ($height == SMALL_IMAGE_HEIGHT)) $borderforimage = 'true';

//end Zebra001 added

 

// alt is added to the img tag even if it is null to prevent browsers from outputting

// the image filename as default

$image = '<img src="' . $src . '" border="0" alt="' . htmlspecialchars($alt) . '"';

 

if (tep_not_null($alt)) {

$image .= ' title=" ' . htmlspecialchars($alt) . ' "';

}

// Zebra001 added

if ($borderforimage == 'true') $image .= ' class=fotgal ';

// end Zebra001 added

}

 

Anyway.......that said, and the colours changed in the stylesheet, still no borders....so I'll putz with it and see what happens.

 

Thank you.

 

Catherine

childcare.net

Posted

this one is ready for the Tips & Tricks

 

still people are asking for this...

Robert

 

We all need to learn it once, how hard it may seem when you look at it, also you will master it someday ;)

Posted

I can get a border on this page, but not the default.php

 

This is the line I added a class="borders" to, and of course that is on the stylesheet. I also put in NULL twice so that I could show the images the actual size. Sorry...I know that is a hack.

 

document.write('<?php echo '<a href="java script:popupWindow('' . tep_href_link(FILENAME_POPUP_IMAGE, 'pID=' . $product_info['products_id']) . '')">' . tep_image(DIR_WS_IMAGES . $product_info['products_image'], $product_info['products_name'], NULL, NULL, 'hspace="5" vspace="5" class="borders"') . '<br>' . TEXT_CLICK_TO_ENLARGE . '</a>'; ?>');

 

If someone knows how to get a border on the default.php product, I'd love to hear about it.

Posted

Annie0,

 

Your solution works even on the default.php page. What are you trying to get borders on the front page for? The, "New Products For this month" products?

 

Regards,

D. Solomon Jr.

3DChipset.com

  • 4 months later...
Posted

TB: Moved this thread to 'Tips and Tricks' forum.

"The price of success is perseverance. The price of failure comes much cheaper."

Posted
i got error with this code.

 

none of them are working with MS1

 

anyone tried this code?

 

I have this working fine. Here is the code I am using. Just look for the following lines in catalog/includes/functions/html_output and place the lines that Zebra001 added and double check your } to make sure it looks like all the code below. Backup this file first before you touch it.

 

 

 

// The HTML image wrapper function

function tep_image($src, $alt = '', $width = '', $height = '', $parameters = '') {

if ( (($src == '') || ($src == DIR_WS_IMAGES)) && (IMAGE_REQUIRED == 'false') ) {

return false;

}

 

// Zebra001 added

$borderforimage = 'false';

if (($width == SMALL_IMAGE_WIDTH) && ($height == SMALL_IMAGE_HEIGHT)) $borderforimage = 'true';

//end Zebra001 added

 

// alt is added to the img tag even if it is null to prevent browsers from outputting

// the image filename as default

$image = '<img src="' . $src . '" border="0" alt="' . htmlspecialchars($alt) . '"';

 

if (tep_not_null($alt)) {

$image .= ' title=" ' . htmlspecialchars($alt) . ' "';

 

// Zebra001 added

if ($borderforimage == 'true') $image .= ' class=fotgal ';

// end Zebra001 added

}

 

Add the following to the bottom of catalog/stylesheet.css I added the visited but you can omit that if you like and you can change the colors to the colors of your choice.

 

.fotgal {border:4px; border-thickness: 4px; border-color: #8080FF;

border-style: solid;

}

 

A:hover .fotgal {border:4px; border-thickness: 4px;

border-color: #FFC0C0; border-style: solid;

}

 

A:active .fotgal {border:4px; border-thickness: 4px;

border-color: #E3E4FF; border-style: solid;

}

A:visited .fotgal {border:4px; border-thickness: 4px;

border-color: #C0C0FF; border-style: solid;

}

 

Have a great day.

Mary :D

Posted

Actually using the stylesheet is easier once you put the code there you don't have to take the time to add borders with image software. Also if you already have alot of images in your shop that would be too time consuming to redo them all.

Mary

Posted

This suggested style sheet settings:

.fotgal {border:2px; border-thickness: 2px; border-color: #ffffff;

border-style: solid;}

A:hover .fotgal, A:active .fotgal {border:2px; border-thickness: 2px;

border-color: purple; border-style: solid}

can be replaced with this:

.fotgal {border:2px #fff solid;}

A:hover .fotgal, A:active .fotgal {border:2px purple solid;}  

does the same, only shorter

 

And if osCommerce is well programmed, only one or two lines in the stylesheet is enough, no other codechanges needed.

 

something like:

img {border:2px #fff solid;}

The images do need to have a class or be in a class to distinct the image from other images (= well programmed) .

Posted

No PHP code change needed!

Simply add the quoted css code to /catalog/stylesheet.css

 

This gives borders in productlisting images only:

table.infoBoxContents td.smalltext img {border: 4px #09f groove;}

 

example (the borders don't seem to fit the images because these images have already two (left and right) large white borders themselves) at:

http://www.televisiedokter.nl/catalog/inde...dex.php?cPath=3 (only temporary available for testing)

 

 

or some more borders like this (i.s.o. the line above):

td.smalltext img {border: 4px #09f groove;}

 

If you want to test/try all (?) CSS borders very fast and easy:

http://artlung.com/lab/css/border-style/

 

hope this is usefull to anyone (or is this to simple?) :?:

Posted

Sorry I just can't get enough of all this. :lol:

 

Add this line to stylesheet.css for a nice hover effect on the borders:

table.infoBoxContents td.smalltext a:hover img {border: 4px red groove;}
Posted

Sorry again:oops:

 

Accidently posted styles for new products image borders in previous post

 

These are the styles to add to catalog/stylesheet.css are for the products image borders:

td.productListing-data img {border: 4px #09f groove;}

td.productListing-data a:hover img {border: 4px red groove;}

 

Hope this is better,

it does work on my testsite.

  • 10 months later...
Posted

Paul

 

Just finished reading your posts about using stylesheets to add image borders. I tried your examples and they worked just fine, I'm trying to add borders to the category images, these are the ones I defined your each sub category.

 

Do you know how this would be achieved ?

 

Your help would be greatly appreciated.

 

Matt

  • 3 weeks later...
Posted

Thank you paulm2003 exelent tip, very helpfull, works very well , just I would like to add the border to the image on the product_info.php/ can you helpme with that

 

THNX :)

  • 1 month later...

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...