*

katalin2k

  • ****
  • 157 posts
Renaming thumbnails to listing title slug
« on: February 08, 2025, 08:14:58 PM »
I would suggest renaming images to product title slug instead of a random string of numbers, it will improve SEO a lot.
In the meanwhile can you tell me where to find the functions that are responsible for image name generation so I can try it myself? I can't seem to find anything related to image renaming...

*

katalin2k

  • ****
  • 157 posts
Re: Renaming thumbnails to listing title slug
« Reply #1 on: February 14, 2025, 09:36:38 PM »
Anyone?

*

MB Themes

Re: Renaming thumbnails to listing title slug
« Reply #2 on: February 18, 2025, 05:10:22 PM »
No plans for that, not simple change.
A lot of core functions, plugins and themes would have to be changed.
  To get fast support, we need following details: Detail description, URL to reproduce problem, Screenshots

*

katalin2k

  • ****
  • 157 posts
Re: Renaming thumbnails to listing title slug
« Reply #3 on: February 20, 2025, 08:01:40 PM »
No plans for that, not simple change.
A lot of core functions, plugins and themes would have to be changed.
If you tell me what files would need modifications I would try to do it myself.

*

MB Themes

Re: Renaming thumbnails to listing title slug
« Reply #4 on: February 20, 2025, 08:18:04 PM »
 :) ... its called development man.
  To get fast support, we need following details: Detail description, URL to reproduce problem, Screenshots

*

katalin2k

  • ****
  • 157 posts
Re: Renaming thumbnails to listing title slug
« Reply #5 on: February 21, 2025, 11:12:58 AM »
:) ... its called development man.
Of course it is but it seems to me you don’t want anyone to do this.

*

MB Themes

Re: Renaming thumbnails to listing title slug
« Reply #6 on: February 21, 2025, 02:40:25 PM »
You have code, you can go for it, but I see this is not work that could be discussed on forums in way "tell me file, line and what code to change..."
  To get fast support, we need following details: Detail description, URL to reproduce problem, Screenshots

*

Wiz

  • ****
  • 170 posts
Re: Renaming thumbnails to listing title slug
« Reply #7 on: February 21, 2025, 04:29:14 PM »
This is actually a very valid point that katalin2k raises as proper/linked filename naming adds context even when image indexing is disabled at the robots.txt file level. Search engines love context and the more context that's provided, the better the ranking.

You should first look at ItemActions.php, specifically uploadItemResources function to get an understanding of how uploaded resources get named, analyze dependencies and identify were changes are needed not just in core, but also in plugins that handle listing resources then code it in.


*

katalin2k

  • ****
  • 157 posts
Re: Renaming thumbnails to listing title slug
« Reply #8 on: July 15, 2025, 05:55:46 PM »
This is actually a very valid point that katalin2k raises as proper/linked filename naming adds context even when image indexing is disabled at the robots.txt file level. Search engines love context and the more context that's provided, the better the ranking.

You should first look at ItemActions.php, specifically uploadItemResources function to get an understanding of how uploaded resources get named, analyze dependencies and identify were changes are needed not just in core, but also in plugins that handle listing resources then code it in.
Did you manage to build such a plugin?

*

MB Themes

Re: Renaming thumbnails to listing title slug
« Reply #9 on: July 16, 2025, 09:23:34 AM »
If you go to your .htaccess file and at very begginning add:
Code: [Select]
# Match: /oc-content/uploads/{DIR}/something-417-thumbnail.jpg
RewriteCond %{DOCUMENT_ROOT}/oc-content/uploads/$1/$2_$3.$4 -f
RewriteRule ^oc-content/uploads/([0-9]+)/.+-([0-9]+)-(thumbnail|preview|normal)\.(jpg|jpeg|png|webp|gif)$ oc-content/uploads/$1/$2_$3.$4 [L]

# Match: /oc-content/uploads/{DIR}/something-417.jpg (original image, no type)
RewriteCond %{DOCUMENT_ROOT}/oc-content/uploads/$1/$2.$3 -f
RewriteRule ^oc-content/uploads/([0-9]+)/.+-([0-9]+)\.(jpg|jpeg|png|webp|gif)$ oc-content/uploads/$1/$2.$3 [L]

You should be able to build your image urls in form: {random-string}-{id}-{type}.{ext}

Example.
Source: https://dev7.abprofitrade.eu/oc-content/uploads/46/417_thumbnail.jpg
Target: https://dev7.abprofitrade.eu/oc-content/uploads/46/some-fancy-string-417-thumbnail.jpg

Testing is required.
  To get fast support, we need following details: Detail description, URL to reproduce problem, Screenshots

*

katalin2k

  • ****
  • 157 posts
Re: Renaming thumbnails to listing title slug
« Reply #10 on: July 16, 2025, 04:13:24 PM »
If you go to your .htaccess file and at very begginning add:
Code: [Select]
# Match: /oc-content/uploads/{DIR}/something-417-thumbnail.jpg
RewriteCond %{DOCUMENT_ROOT}/oc-content/uploads/$1/$2_$3.$4 -f
RewriteRule ^oc-content/uploads/([0-9]+)/.+-([0-9]+)-(thumbnail|preview|normal)\.(jpg|jpeg|png|webp|gif)$ oc-content/uploads/$1/$2_$3.$4 [L]

# Match: /oc-content/uploads/{DIR}/something-417.jpg (original image, no type)
RewriteCond %{DOCUMENT_ROOT}/oc-content/uploads/$1/$2.$3 -f
RewriteRule ^oc-content/uploads/([0-9]+)/.+-([0-9]+)\.(jpg|jpeg|png|webp|gif)$ oc-content/uploads/$1/$2.$3 [L]

You should be able to build your image urls in form: {random-string}-{id}-{type}.{ext}

Example.
Source: https://dev7.abprofitrade.eu/oc-content/uploads/46/417_thumbnail.jpg
Target: https://dev7.abprofitrade.eu/oc-content/uploads/46/some-fancy-string-417-thumbnail.jpg

Testing is required.
It would be great but can I use slug from product title?

*

MB Themes

Re: Renaming thumbnails to listing title slug
« Reply #11 on: July 17, 2025, 08:02:09 PM »
There is function that generates slug.
Try

Code: [Select]
<?php echo osc_sanitizeString(osc_item_title()); ?>
Check for more functions:
https://docs.osclass-classifieds.com/hitems-php-i46
  To get fast support, we need following details: Detail description, URL to reproduce problem, Screenshots

*

katalin2k

  • ****
  • 157 posts
Re: Renaming thumbnails to listing title slug
« Reply #12 on: July 17, 2025, 11:38:33 PM »
There is function that generates slug.
Try

Code: [Select]
<?php echo osc_sanitizeString(osc_item_title()); ?>
Check for more functions:
https://docs.osclass-classifieds.com/hitems-php-i46
Ok but why don’t you add image renaming to SEO Pro Plugin or Webp plugin? Or maybe even a new plugin? As you may know image name, alt and title are quite important for SEO.

*

MB Themes

Re: Renaming thumbnails to listing title slug
« Reply #13 on: July 18, 2025, 10:12:29 AM »
@katalin2k
Because "image name" does not exists and would cause incompatibility with many themes, plugins and core features.
  To get fast support, we need following details: Detail description, URL to reproduce problem, Screenshots

*

katalin2k

  • ****
  • 157 posts
Re: Renaming thumbnails to listing title slug
« Reply #14 on: July 18, 2025, 09:50:23 PM »
@katalin2k
Because "image name" does not exists and would cause incompatibility with many themes, plugins and core features.
I understand but most websites now use product title as slug for image title. You should update in next version of osclass or if possible build or integrate with another plugin like I said before.