Keyword

Where K2 store articles images in database?

More
12 years 10 months ago #90490 by Pixeden
Replied by Pixeden on topic Where K2 store articles images in database?
Joomla/K2 replaces some characters in the filename when uploading/saving the image:

 

It is not joomla/K2, but the way the file upload class used by k2 from verot.net that strip special character like dash and empty space for underscore. For your case just go to administrator/components/com_k2/models/item.php and in every image creation (//Original image, //XLarge image etc...) add:

$handle->file_safe_name = false;

And magic dashes are back, no much point of going seo and having only underscores and not dashes as all know.

Just be sure that when you write the image name to use only characters allowed so that the image link works.

You can learn more here about options of the upload class:

www.verot.net/php_class_upload_docs.htm

 

Anyhow thanks for the post as it saved me a bit of time looking into it,

Now the preview image disapears in admin (it calls a item->thumb and not normal images, just have to find where it is and we have a complete k2 seo image optimization.) If anyone has a tip here, it is welcome.

 

Markus Amanto said:

One additional thing I noticed in the process. Joomla/K2 replaces some characters in the filename when uploading/saving the image which messed it up a bit for me at first, but in case that happens to you, you can use an ftp program to check the image folder and see what name your files have been given and then just make sure that what you have entered in the "Item image credits" matches that.

For example in my case it replaces my dashes that I first entered in the filename with underscores.

 

 

Please Log in or Create an account to join the conversation.

More
12 years 9 months ago #90491 by Pixeden
Replied by Pixeden on topic Where K2 store articles images in database?
Don't forget that if you use the module k2 content

You also have to modify:

modules/mod_k2_content/helper.php

 

line 226 replace for:

 

$myfilename = $item->image_credits;if (JFile::exists(JPATH_SITE.DS.'media'.DS.'k2'.DS.'items'.DS.'cache'.DS.$myfilename.'_XS.jpg')) $item->imageXSmall = JURI::root().'media/k2/items/cache/'.$myfilename.'_XS.jpg';if (JFile::exists(JPATH_SITE.DS.'media'.DS.'k2'.DS.'items'.DS.'cache'.DS.$myfilename.'_S.jpg')) $item->imageSmall = JURI::root().'media/k2/items/cache/'.$myfilename.'_S.jpg';if (JFile::exists(JPATH_SITE.DS.'media'.DS.'k2'.DS.'items'.DS.'cache'.DS.$myfilename.'_M.jpg')) $item->imageMedium = JURI::root().'media/k2/items/cache/'.$myfilename.'_M.jpg';if (JFile::exists(JPATH_SITE.DS.'media'.DS.'k2'.DS.'items'.DS.'cache'.DS.$myfilename.'_L.jpg')) $item->imageLarge = JURI::root().'media/k2/items/cache/'.$myfilename.'_L.jpg';if (JFile::exists(JPATH_SITE.DS.'media'.DS.'k2'.DS.'items'.DS.'cache'.DS.$myfilename.'_XL.jpg')) $item->imageXLarge = JURI::root().'media/k2/items/cache/'.$myfilename.'_XL.jpg';if (JFile::exists(JPATH_SITE.DS.'media'.DS.'k2'.DS.'items'.DS.'cache'.DS.$myfilename.'_Generic.jpg')) $item->imageGeneric = JURI::root().'media/k2/items/cache/'.$myfilename.'_Generic.jpg';

Please Log in or Create an account to join the conversation.

More
12 years 7 months ago #90492 by Asiya Novik
Replied by Asiya Novik on topic Where K2 store articles images in database?
to show preview in back-end i've modified file

/administrator/components/com_k2/views/item/tmpl/default.php

lines 322-333:

<?php if (!empty($this->row->image_credits)): ?>                              <tr>                                <td align="right" class="key"><?php echo JText::_('Item image preview'); ?></td>                                <td>                                  <a class="modal" href="<?php echo $this->row->image; ?>" title="<?php echo JText::_('Click on image to preview in original size'); ?>">                                      <img alt="<?php echo $this->row->title; ?>" src="<?php $myfilename = $this->row->image_credits; echo JURI::root()."/media/k2/items/cache/".$myfilename."_S.jpg"; ?>" class="k2AdminImage"/>                                  </a>                                  <input type="checkbox" name="del_image" id="del_image" />                                  <label for="del_image"><?php echo JText::_('Check this box to delete current image or just upload a new image to replace the existing one'); ?></label>                                </td>                              </tr>  <?php endif; ?>

Please Log in or Create an account to join the conversation.

More
12 years 7 months ago #90493 by Pixeden
Replied by Pixeden on topic Where K2 store articles images in database?
Thanks, i didn't go in finding it myself, just made the change, works perfectly.

Don't forget to change the href of the modal popup link :

<a class="modal" href="<?php echo $this->row->image; ?>" title="<?php echo JText::_('Click on image to preview in original size'); ?>">

to

<a class="modal" href="<?php $myfilename = $this->row->image_credits; echo JURI::root()."/media/k2/items/cache/".$myfilename."_M.jpg"; ?>" title="<?php echo JText::_('Click on image to preview in original size'); ?>">

for instance.

 

Asiya said:

to show preview in back-end i've modified file

/administrator/components/com_k2/views/item/tmpl/default.php

lines 322-333:

<?php if (!empty($this->row->image_credits)): ?>                              <tr>                                <td align="right" class="key"><?php echo JText::_('Item image preview'); ?></td>                                <td>                                  <a class="modal" href="<?php echo $this->row->image; ?>" title="<?php echo JText::_('Click on image to preview in original size'); ?>">                                      <img alt="<?php echo $this->row->title; ?>" src="<?php $myfilename = $this->row->image_credits; echo JURI::root()."/media/k2/items/cache/".$myfilename."_S.jpg"; ?>" class="k2AdminImage"/>                                  </a>                                  <input type="checkbox" name="del_image" id="del_image" />                                  <label for="del_image"><?php echo JText::_('Check this box to delete current image or just upload a new image to replace the existing one'); ?></label>                                </td>                              </tr>  <?php endif; ?>

Please Log in or Create an account to join the conversation.


Powered by Kunena Forum