How to Change Relative Image Paths to Absolute Paths in ECSHOP Source Code

1. How to Change ECSHOP Ad Image Relative Paths /data/afficheimg/ to Absolute Paths? Modification method: Modify the function insert_ads($arr) in the Includes/lib_insert.php file

case 0: // Image ad

$src = (strpos($row['ad_code'], 'http://') === false && strpos($row['ad_code'], 'https://') === false) ? 'http://www.taoyuan99.com/'.DATA_DIR . "/afficheimg/$row[ad_code]" : $row['ad_code'];

2. How to Change ECSHOP Product Image Relative Paths to Absolute Paths? You need to modify 2 places. Modify the function get_image_path in the Includes/lib_common.php file. Search for: Rewrite URL address, in the function build_uri below. Add below $uri = '';

$weburl = 'http://'.$_SERVER['SERVER_NAME'].'/';

Then replace the return $uri; below with return $weburl . $uri;

Find the image formatting function get_image_path. Replace return $url; with return (strpos($url, 'http://') === false && strpos($url, 'https://') === false) ? 'http://www.taoyuan99.com/'.$url : $url;

After modification, it will look like this: function get_image_path($goods_id, $image='', $thumb=false, $call='goods', $del=false) { $url = empty($image) ? $GLOBALS['_CFG']['no_picture'] : $image; return (strpos($url, 'http://') === false && strpos($url, 'https://') === false) ? 'http://www.taoyuan99.com/'.$url : $url; }

3. Change Images in Product Page Descriptions to Absolute Paths. Directly modify the database. ECSHOP Backend—— > Database Management—— > SQL Query. Run: update ecs_goods set goods_desc=replace (goods_desc,'src="/images/upload/','src=" http://www.taoyuan99.com/images/upload/') After these steps, the relative image paths in your ECSHOP storefront source code will now be absolute paths. Of course, there may be other places that need modification, and everyone can discover new methods themselves. Reminder: Be sure to replace the example URL with your own. Additionally, always back up your files or database before making modifications.

Leave a Comment

Your email address will not be published.