wellington_implement Posted April 29, 2009 Share Posted April 29, 2009 Hi, I am trying to put together an online store. I have it set up for the most part there is just one problem I cannot find the answer for. The store that I am working on is for apparel. We have images of t-shirts with a design on them. We also have images of just the design/logo that is on the tshirt. There is a link that says click to enlarge. We would like that link to go to the image with the design/logo on it. the file names are set up as 123456.jpg for the design/logo and 123456_t for the t-shirts. Any help would be appreciated. Many thanks in advance. Jevon Quote Link to comment https://forums.phpfreaks.com/topic/156190-changing-pop-up-window-image/ Share on other sites More sharing options...
mikesta707 Posted April 29, 2009 Share Posted April 29, 2009 well you could take the file name of the image, and then explode the string using the delimiter '.' and that would give you two arrays with the file name as the first value, and the extension of the second. You could then append the file name with '_t' and then implode the array using '.' as the glue. Then you take your "fixed" image source, and when you output the image, echo that variable as the source Quote Link to comment https://forums.phpfreaks.com/topic/156190-changing-pop-up-window-image/#findComment-822257 Share on other sites More sharing options...
taith Posted April 29, 2009 Share Posted April 29, 2009 or just str_replace('.','-t.',$url); Quote Link to comment https://forums.phpfreaks.com/topic/156190-changing-pop-up-window-image/#findComment-822285 Share on other sites More sharing options...
wellington_implement Posted April 30, 2009 Author Share Posted April 30, 2009 Below is the code that I am using for the pop up. I am new to php all together so I have no clue what I am really doing. Any help would be nice. <?php /* $Id: popup_image.php osCommerce, Open Source E-Commerce Solutions http://www.oscommerce.com Copyright © 2003 osCommerce Copyright © 2008 Club osCommerce www.clubosc.com Released under the GNU General Public License */ require('includes/application_top.php'); $products_query = tep_db_query("select pd.products_name, p.products_image from " . TABLE_PRODUCTS . " p left join " . TABLE_PRODUCTS_DESCRIPTION . " pd on p.products_id = pd.products_id where p.products_status = '1' and p.products_id = '" . (int)$HTTP_GET_VARS['pID'] . "' and pd.language_id = '" . (int)$languages_id . "'"); $products = tep_db_fetch_array($products_query); //do for different filetypes $old = array(".jpg", ".jpeg", ".gif", ".png"); $new = array("_t.jpg", "_t.jpeg", "_t.gif", "_t.png"); //append "_t" to filename $product_image_logo = str_replace($old, $new, $products['products_image']); //check if file exists if (file_exists(DIR_WS_IMAGES . $product_image_logo)) { //if it does then display "_t" image $products['products_image'] = $product_image_logo; } //do for different filetypes $old = array("_T.jpg", "._Tjpeg", "_T.gif", "_T.png"); $new = array(".jpg", ".jpeg", ".gif", ".png"); //append "" to filename $product_image_logo = str_replace($old, $new, $products['products_image']); //check if file exists if (file_exists(DIR_WS_IMAGES . $product_image_logo)) { //if it does then display "_t" image $products['products_image'] = $product_image_logo; } ?> <!doctype html public "-//W3C//DTD HTML 4.01 Transitional//EN"> <html <?php echo HTML_PARAMS; ?>> <head> <meta http-equiv="Content-Type" content="text/html; charset=<?php echo CHARSET; ?>"> <title><?php echo $products['products_name']; ?></title> <base href="<?php echo (($request_type == 'SSL') ? HTTPS_SERVER : HTTP_SERVER) . DIR_WS_CATALOG; ?>"> <script language="javascript"><!-- var i=0; function resize() { if (navigator.appName == 'Netscape') i=40; if (document.images[0]) window.resizeTo(document.images[0].width +90, document.images[0].height+150-i); self.focus(); } //--></script> </head> <body onload="resize();"> <?php if (tep_not_null($products['large_products_image'])) { echo tep_image(DIR_WS_IMAGES . $products['large_products_image'], $products['products_name']); } else { echo tep_image(DIR_WS_IMAGES . $products['products_image'], $products['products_name']); } ?> </body> </html> <?php require('includes/application_bottom.php'); ?> Thanks, Jevon Quote Link to comment https://forums.phpfreaks.com/topic/156190-changing-pop-up-window-image/#findComment-822552 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.