Ramin007 Posted August 28, 2016 Share Posted August 28, 2016 (edited) after enabling "friendly urls" in prestashop management panel, all urls and image urls will change into something like this: http://example.com/1545-large_default/1545.jpg how can I disable friendly urls just for images? note that, I want to disable it just for images not all other urls! I think it's done by changing some PHP codes, etc. I'm not a php programmer and I don't know what should I do! Help me please. Edited September 2, 2016 by Ramin007 (see edit history) Link to comment Share on other sites More sharing options...
Prestachamps Posted August 28, 2016 Share Posted August 28, 2016 Hi, you could try to disable the htaccess rules that are used for image frendly url redirection, and to override the image link generation function from the image class. Regards, Leo 2 Link to comment Share on other sites More sharing options...
Ramin007 Posted August 29, 2016 Author Share Posted August 29, 2016 (edited) Hi leo, thank you for answering. - Which htaccess rules shoud be disabled? can you please give me the rules that should be disabled? and to override the image link generation function from the image class. - Where is "image class"? what should I do exactly? (Step by step) Thanks. Edited August 29, 2016 by Ramin007 (see edit history) Link to comment Share on other sites More sharing options...
Prestachamps Posted August 29, 2016 Share Posted August 29, 2016 Hi, the image class is in the /classes folder, the good and best way is to override the function in the /override/classes folder. 1. what version of prestashop are you using? 2. Do you have default theme of prestashop? Regards, Leo 1 Link to comment Share on other sites More sharing options...
Ramin007 Posted August 29, 2016 Author Share Posted August 29, 2016 (edited) Dear Leo, thank you again for your answer. the image class is in the /classes folder, the good and best way is to override the function in the /override/classes folder. Sorry, I'm newbie. Can you please tell me what shoud I do exactly? What files shoud I edit? What codes should I insert? Please explain it in details. ---------------- 1. I use PS v1.6.1.5 2. No I use an custom theme. Edited August 29, 2016 by Ramin007 (see edit history) Link to comment Share on other sites More sharing options...
Ramin007 Posted August 30, 2016 Author Share Posted August 30, 2016 Any idea? Link to comment Share on other sites More sharing options...
PrestaHeroes USA Posted August 30, 2016 Share Posted August 30, 2016 I'm really curious as to why you want to disable friendly url for images. Also this would require change to .htaccess file ps builds, and change not to build them on regeneration. 1 Link to comment Share on other sites More sharing options...
Ramin007 Posted August 30, 2016 Author Share Posted August 30, 2016 (edited) Thank you El Patron for answering For some reasons we have to disable url friendly for images. please just tell me the steps should be done. Which rules should I remove from .htaccess file? Which files should I edit in /override/classes directory? I'm not a PHP programmer please tell me what should I spouse to do? Please explain it in details Thanks Edited August 30, 2016 by Ramin007 (see edit history) Link to comment Share on other sites More sharing options...
PrestaHeroes USA Posted August 31, 2016 Share Posted August 31, 2016 I think you will need tot find a php programmer unless one of community is going to spend hours seeing if they can make the code work. Also 'for some reason', you explanation of requirement would be most helpful to community to know as there may be 'no reason' to do this and there we might be able to provide some insight. 1 Link to comment Share on other sites More sharing options...
Prestachamps Posted August 31, 2016 Share Posted August 31, 2016 Hi, please be aware of the fact that this is a core modification, and the changes you are doing in the htaccess file will be reverted next time the htacccess will be regenerated by the prestashop ( please test this modifications on a development version before applying it to a live environment ) This modification usually should work with custom themes too, not only with the default theme. For the product images these are the 3 steps to disable the rewrites and image link generation: 1: in .htaccess comment the lines that are referring to the .... img/p .... . this is the commented code from htaccess for domain.com : " #RewriteCond %{HTTP_HOST} ^domain.com$ #RewriteRule ^([0-9])(\-[_a-zA-Z0-9-]*)?(-[0-9]+)?/.+\.jpg$ %{ENV:REWRITEBASE}img/p/$1/$1$2$3.jpg [L] #RewriteCond %{HTTP_HOST} ^domain.com$ #RewriteRule ^([0-9])([0-9])(\-[_a-zA-Z0-9-]*)?(-[0-9]+)?/.+\.jpg$ %{ENV:REWRITEBASE}img/p/$1/$2/$1$2$3$4.jpg [L] #RewriteCond %{HTTP_HOST} ^domain.com$ #RewriteRule ^([0-9])([0-9])([0-9])(\-[_a-zA-Z0-9-]*)?(-[0-9]+)?/.+\.jpg$ %{ENV:REWRITEBASE}img/p/$1/$2/$3/$1$2$3$4$5.jpg [L] #RewriteCond %{HTTP_HOST} ^domain.com$ #RewriteRule ^([0-9])([0-9])([0-9])([0-9])(\-[_a-zA-Z0-9-]*)?(-[0-9]+)?/.+\.jpg$ %{ENV:REWRITEBASE}img/p/$1/$2/$3/$4/$1$2$3$4$5$6.jpg [L] #RewriteCond %{HTTP_HOST} ^domain.com$ #RewriteRule ^([0-9])([0-9])([0-9])([0-9])([0-9])(\-[_a-zA-Z0-9-]*)?(-[0-9]+)?/.+\.jpg$ %{ENV:REWRITEBASE}img/p/$1/$2/$3/$4/$5/$1$2$3$4$5$6$7.jpg [L] #RewriteCond %{HTTP_HOST} ^domain.com$ #RewriteRule ^([0-9])([0-9])([0-9])([0-9])([0-9])([0-9])(\-[_a-zA-Z0-9-]*)?(-[0-9]+)?/.+\.jpg$ %{ENV:REWRITEBASE}img/p/$1/$2/$3/$4/$5/$6/$1$2$3$4$5$6$7$8.jpg [L] #RewriteCond %{HTTP_HOST} ^domain.com$ #RewriteRule ^([0-9])([0-9])([0-9])([0-9])([0-9])([0-9])([0-9])(\-[_a-zA-Z0-9-]*)?(-[0-9]+)?/.+\.jpg$ %{ENV:REWRITEBASE}img/p/$1/$2/$3/$4/$5/$6/$7/$1$2$3$4$5$6$7$8$9.jpg [L] #RewriteCond %{HTTP_HOST} ^domain.com$ #RewriteRule ^([0-9])([0-9])([0-9])([0-9])([0-9])([0-9])([0-9])([0-9])(\-[_a-zA-Z0-9-]*)?(-[0-9]+)?/.+\.jpg$ %{ENV:REWRITEBASE}img/p/$1/$2/$3/$4/$5/$6/$7/$8/$1$2$3$4$5$6$7$8$9$10.jpg [L] " 2: create Link.php file in the folder /override/clasess/ . this file should contain this code: " <?php class Link extends LinkCore { public function getImageLink($name, $ids, $type = null) { // $not_default = false; $not_default = true; // Check if module is installed, enabled, customer is logged in and watermark logged option is on if (Configuration::get('WATERMARK_LOGGED') && (Module::isInstalled('watermark') && Module::isEnabled('watermark')) && isset(Context::getContext()->customer->id)) { $type .= '-'.Configuration::get('WATERMARK_HASH'); } // legacy mode or default image $theme = ((Shop::isFeatureActive() && file_exists(_PS_PROD_IMG_DIR_.$ids.($type ? '-'.$type : '').'-'.(int)Context::getContext()->shop->id_theme.'.jpg')) ? '-'.Context::getContext()->shop->id_theme : ''); // if ((Configuration::get('PS_LEGACY_IMAGES') // && (file_exists(_PS_PROD_IMG_DIR_.$ids.($type ? '-'.$type : '').$theme.'.jpg'))) // || ($not_default = strpos($ids, 'default') !== false)) { // if ($this->allow == 1 && !$not_default) { // $uri_path = __PS_BASE_URI__.$ids.($type ? '-'.$type : '').$theme.'/'.$name.'.jpg'; // } else { // $uri_path = _THEME_PROD_DIR_.$ids.($type ? '-'.$type : '').$theme.'.jpg'; // } // } else { // if ids if of the form id_product-id_image, we want to extract the id_image part $split_ids = explode('-', $ids); $id_image = (isset($split_ids[1]) ? $split_ids[1] : $split_ids[0]); $theme = ((Shop::isFeatureActive() && file_exists(_PS_PROD_IMG_DIR_.Image::getImgFolderStatic($id_image).$id_image.($type ? '-'.$type : '').'-'.(int)Context::getContext()->shop->id_theme.'.jpg')) ? '-'.Context::getContext()->shop->id_theme : ''); // if ($this->allow == 1) { // $uri_path = __PS_BASE_URI__.$id_image.($type ? '-'.$type : '').$theme.'/'.$name.'.jpg'; // } else { $uri_path = _THEME_PROD_DIR_.Image::getImgFolderStatic($id_image).$id_image.($type ? '-'.$type : '').$theme.'.jpg'; // } // } return $this->protocol_content.Tools::getMediaServer($uri_path).$uri_path; } } " 3: delete or rename the file /cache/class_index.php so the override should be taken in consideration at the next pageload. I am really curious about the fact that why you don't need rewrite for images? Regards, Leo 4 1 Link to comment Share on other sites More sharing options...
Ramin007 Posted August 31, 2016 Author Share Posted August 31, 2016 Thank you dear Leo. It worked!! You're a good programmer dear Leo. Thank you in advance. Link to comment Share on other sites More sharing options...
Prestachamps Posted September 2, 2016 Share Posted September 2, 2016 Hi, please mark the thread as SOLVED, by editing the title and add [sOLVED] at the beginning of the thread title. Thanks, Regards, Leo 1 Link to comment Share on other sites More sharing options...
Ramin007 Posted September 2, 2016 Author Share Posted September 2, 2016 Done. Thank you again Mr Leo. Good luck. Link to comment Share on other sites More sharing options...
Prestan0ob Posted March 11, 2023 Share Posted March 11, 2023 Any solution to disable prduct images friendly URL's in Prestashop 1.7.8 please? Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now