toolshop Posted November 28, 2013 Posted November 28, 2013 Product images are presented as follow: /images/product_images/info_images/11266_0.jpg. Google does not like this and prefers the products_name as image name instead of the products_id. It should be: /images/product_images/info_images/Rowi Blue Flame 4200 Gasofen_0.jpg Question is: How to rewrite the image url. I have tryed this code I got from someone in .htacces but it can not work while the products_name is unknown RewriteCond %{REQUEST_FILENAME} -l RewriteRule %{REQUEST_FILENAME} - [NC,L] RewriteRule ^(.*_)([0-9]+_[0-9]+\.)(gif|png|jpg|jpeg)$ $2$3 [NC,L] Does anyone knows how to fix this? Would be fine. Thanks in advance.
♥joli1811 Posted November 28, 2013 Posted November 28, 2013 Hi Ronald, Well interesting subject I sort of suspected this over the years just alone that the image, properly named, would possibly appear quicker in google image results and thus might have a SEO factor so do try to name my images after the product Never seen a discussion or info on this so it is an interesting subject. Oh sorry no idea of a rewrite that would do that maybe someone has an idea / opinion.? Regards Joli To improve is to change; to be perfect is to change often.
MrPhil Posted November 29, 2013 Posted November 29, 2013 What exactly are you trying to accomplish here? Does it really matter what Google thinks of your image names, unless you're anxious to get them into Google Images? If that's the case, I understand that various SEO add-ons tend to not do anything to image names, just page links. You could go through the code (tep_image?) and modify it to use an SEO-style name, if you think it's worth the effort. Note that .htaccess would then have to decode image names in the same way it does page names. The product_id has to be in the URI somewhere, so the name .../11266_0/Rowi Blue Flame 4200 Gasofen.jpg gets translated into .../11266_0.jpg (in this case, by discarding the descriptive name).
burt Posted November 29, 2013 Posted November 29, 2013 Why complicate things? When you create a product, use an image of the same name as the product. Or rewrite the product name as part of the upload process. If you have a bunch of images to rename, write a PHP script to; a. get an array of all the images and product names b. for each one, rename it c. and then update the relevant product record appropriately
toolshop Posted December 1, 2013 Author Posted December 1, 2013 Do have a solution nowbut you have to work with Smarty tags. In the wanted image map write this modrewrite in a .htaccess file: 1 <IfModule mod_rewrite.c> RewriteEngine On RewriteCond %{REQUEST_FILENAME} -l RewriteRule %{REQUEST_FILENAME} - [NC,L] RewriteRule ^(.*_)([0-9]+_[0-9]+\.)(gif|png|jpg|jpeg)$ $2$3 [NC,L] </IfModule> In the Smarty map /plugins place this new file: modifier.imageRename.php function smarty_modifier_imageRename($string,$newpart){ $insert=urlencode($newpart)."_"; $pos=strrpos($string,"/"); if ($pos === false) { return $string; } else { return substr($string,0,$pos+1).$insert.substr($string,$pos+1); } } To get this codes running edit the template file for instance products_listing and change the code as written below: 1 {$PRODUCTS_IMAGE} wijzigen in {$PRODUCTS_IMAGE|imageRename:$PRODUCTS_NAME} Thats it. Result is now productname + products_id : /images/product_images/info_images/Eurom+Milano+deluxe+Ventilator+met+afstandsbediening_11209_0.jpg
Recommended Posts
Archived
This topic is now archived and is closed to further replies.