SEO k2 image

Feel free to talk about everything related to our Joomla Products
Rate this topic: Evaluations: 0, 0.00 on the average.Evaluations: 0, 0.00 on the average.Evaluations: 0, 0.00 on the average.Evaluations: 0, 0.00 on the average.Evaluations: 0, 0.00 on the average.Evaluations: 0, 0.00 on the average.
GK User
Mon Jul 23, 2012 3:56 pm
Hi my friends. I have noticed that in k2 article, k2 images lose their name. If my image is name.jpg, in the article is ex: 01265784df2g55f5d2s.jpg. Why? How can I maintain their original name? with aphanumerical name i lose my seo.

anyone knows a solution?
User avatar
Expert Boarder

GK User
Tue Jul 24, 2012 7:33 am
Reason behind their naming is so each image is unique to their item id to prevent image name problems or for security reasons. They are using md5 hash to create filenames.

Here is an example for you if you want to make the changes.

You can change to itemtitle + itemid.jpg if you like. So it would look like below example. Please note third party plugins or modules which looks for original code might not work with this mod or you would have to change them as well.

Title: Super Outing Massimo Dutti Sport
Code: Select all
Main Image:
Super_Outing_Massimo_Dutti_Sport_1.jpg
Cache Files:
Super_Outing_Massimo_Dutti_Sport_1_Generic.jpg
Super_Outing_Massimo_Dutti_Sport_1_L.jpg
Super_Outing_Massimo_Dutti_Sport_1_M.jpg
Super_Outing_Massimo_Dutti_Sport_1_S.jpg
Super_Outing_Massimo_Dutti_Sport_1_XL.jpg
Super_Outing_Massimo_Dutti_Sport_1_XS.jpg

See following file for naming code.
File: administrator\components\com_k2\models\item.php
Find Line: 295
Code:
Code: Select all
                $handle->file_new_name_body = md5("Image".$row->id);

Replace it with below code:
Code: Select all
                $handle->file_new_name_body = $row->title . $row->id;

Now you need to find and change every instance of original code to changed code in following files.
Code: Select all
administrator\components\com_k2\models\item.php
administrator\components\com_k2\models\items.php
administrator\components\com_k2\views\item\view.html.php
administrator\components\com_k2\views\items\tmpl\default.php
components\com_k2\models\item.php
components\com_k2\models\itemlist.php
modules\mod_k2_content\helper.php
modules\mod_news_pro_gk4\tmpl\layout.parts.php


Change where exists with new code
Code: Select all
.md5("Image".$row->id).  change to .$row->title.$row->id.
md5("Image".$current->id) change to $current->title.$current->id;
.md5("Image".$item->id).  change to .$item->title.$item->id.
.md5("Image".$news_id).  change to .$news_title.$news_id.


See you around...
User avatar
Platinum Boarder

GK User
Tue Jul 24, 2012 10:55 am
Hi normanUK,

I tried to make the changes you show me. but the result is that if I change the file "components\com_k2\models\item.php" the article image and the image in gk4 module disappears. Why? I make the sequence 2 times. so i don't understand why it doesn't work.

If you want this is my site http://www.alessandrodalmoro.com/dairykey/
User avatar
Expert Boarder

GK User
Tue Jul 24, 2012 11:08 am
Check the cache folder to see if the images are there with your changed name.

/media/k2/items/cache
/media/k2/items/src

Probably forgot to make a change somewhere where its still using old code.

See you around...
User avatar
Platinum Boarder

GK User
Tue Jul 24, 2012 11:26 am
Sorry, I forgot to reload image in articles. If I reload it I see the new image.

Thanks a lot. Now I see the correct name, good for the seo. ;)
User avatar
Expert Boarder

GK User
Tue Jul 24, 2012 11:39 am
No problem at all, you might want to package your changed files as zip file and attach it here for others to use. That would help save them a time ;)

See you around...
User avatar
Platinum Boarder

GK User
Tue Jul 24, 2012 12:04 pm
sure. but I have a little problem, it take the name from the title of the article. if the article has a space it doen't create the image!!!
User avatar
Expert Boarder

GK User
Tue Jul 24, 2012 12:23 pm
What is the name of the images when you use empty space in your item title. If they also have empty spaces then we could use alias instead of title as alias never gets empty space.
Code: Select all
                $handle->file_new_name_body = $row->alias.$row->id;
.md5("Image".$row->id).  change to .$row->alias.$row->id.
md5("Image".$current->id) change to $current->alias.$current->id;
.md5("Image".$item->id).  change to .$item->alias.$item->id.
.md5("Image".$news_id).  change to .$news_alias.$news_id.

Last one from news show pro might not work with $news_alias by default. We need to double check that.

Let me know , see you around...
User avatar
Platinum Boarder

GK User
Tue Jul 24, 2012 12:38 pm
I write you an example. The name of the image that I load is "name.jpg" and the name of the title is "title", the result is that the image takes the name of the title instead of mantain his own name. However in this case I can load the image.
If the title is "title title", with an empty space, is not possible to load the image in backend and I don't know why.
User avatar
Expert Boarder

GK User
Tue Jul 24, 2012 1:21 pm
Great job!! now it load images correctly! how can I upload the folder with the php modified files in this post?
User avatar
Expert Boarder

GK User
Tue Jul 24, 2012 1:23 pm
You can make a zip file and use "upload attachment" option while posting a reply just below submit button.

See you around...
User avatar
Platinum Boarder

GK User
Tue Jul 24, 2012 1:32 pm
Sorry, I didn't see it.. :P

So, here there is the folder with php file.
file_php_package.zip


Thanks for helping me. See you around normanUK!
User avatar
Expert Boarder

GK User
Tue Jul 24, 2012 1:39 pm
No problems at all, thank you for the zip file, I am sure it will be helpful to other users.

See you around...

Repacked zip file with correct folder structure ready to upload to website.
Please backup your website before uploading files.
Contains edited K2 v2.5.7 files and News Show Pro GK4 3.13 file

Search Terms;

K2 Edit image Name, K2 change image name, K2 change image filename.
User avatar
Platinum Boarder

Mi Media
Wed Jan 23, 2013 5:33 pm
normanUK wrote:No problems at all, thank you for the zip file, I am sure it will be helpful to other users.

See you around...

Repacked zip file with correct folder structure ready to upload to website.
Please backup your website before uploading files.
Contains edited K2 v2.5.7 files and News Show Pro GK4 3.13 file

Search Terms;

K2 Edit image Name, K2 change image name, K2 change image filename.


Please normanUK, can you make the appropriate changes of the code for K2 v2.6.2?
It would be much appreciated.
User avatar

GK User
Fri Feb 01, 2013 10:26 am
Being away for few months now , need to catch up with release ;) I ll do it as soon as possible.

See you around...
User avatar
Platinum Boarder

GK User
Wed Jul 17, 2013 2:20 pm
Hi,
I'd be interested in the updated version, too.
Are you still working on it?
Thank you!
User avatar
Fresh Boarder

GK User
Sun Aug 11, 2013 7:56 am
I ll do this Tuesday or Wednesday.

See you around...
User avatar
Platinum Boarder

GK User
Thu Aug 15, 2013 1:00 am
Done & tested.

K2 2.6.7, full package.
NSP GK5 v1.22 Full package.
User avatar
Platinum Boarder

GK User
Mon Jul 21, 2014 1:12 pm
normanUK wrote:Done & tested.

K2 2.6.7, full package.
NSP GK5 v1.22 Full package.


please can you upload again these ATTACHMENTS?
User avatar
Fresh Boarder

GK User
Sun Jan 17, 2016 5:32 am
Hi, could you check it? Please!
User avatar
Fresh Boarder

GK User
Sun Jan 17, 2016 3:54 pm
Hi everyone :)
I tried to contact normalUK via private message, but with no luck. Maybe someone else can help? I have just changed my k2 settings to the ones that show .alias as filename. Everything works like charm in K2, but I have no idea how to change values in NewsShowProgk5. I tried to put .alias instead of .md5("Image".$item['id']). in view.php but then the module breaks. Any ideas?
User avatar
Fresh Boarder

GK User
Fri May 13, 2016 5:31 am
I will update the mod with latest versions, testing at the moment.

Przemo82cs wrote:Hi everyone :)
I tried to contact normalUK via private message, but with no luck. Maybe someone else can help? I have just changed my k2 settings to the ones that show .alias as filename. Everything works like charm in K2, but I have no idea how to change values in NewsShowProgk5. I tried to put .alias instead of .md5("Image".$item['id']). in view.php but then the module breaks. Any ideas?

Przemo82cs, use following code $item['alias'], see below code in
File: modules\mod_news_pro_gk5\tmpl\com_k2\view.php
Line: 293
Code: Select all
      } else {
         // search for the article featured image
         if(JFile::exists(JPATH_SITE.DS.'media'.DS.'k2'.DS.'items'.DS.'cache'.DS.$item['alias'].$item['id'].'_'.$config['k2_image_size'].'.jpg')){ 
            $IMG_SOURCE = JURI::root().'media/k2/items/cache/'.$item['alias'].$item['id'].'_'.$config['k2_image_size'].'.jpg';
         } elseif(JFile::exists(JPATH_SITE.DS.'media'.DS.'k2'.DS.'items'.DS.'cache'.DS.$item['alias'].$item['id'].'_'.$config['k2_image_size'].'.png')){ 
               $IMG_SOURCE = JURI::root().'media/k2/items/cache/'.$item['alias'].$item['id'].'_'.$config['k2_image_size'].'.png';
         }
      }
User avatar
Platinum Boarder


cron