COMMUNITY FORUM
Search Results (Searched for: change K2 item images path)
- Jonathan Roza
Feature request: image inherit on multi-language
Category: English K2 Community
We have a multi-language website with a lot of items, growing in number every day.
The secondary language items are allways a direct translation of the main language, with the same images.
To reduce cache size, workload on generation of cache, and overall backup size, we would like to make all the secondary language items use the cached images of the main item.
Currently, each item have its own src image, and set of cached images in 6 sizes. So in the end, for each item (adding main and translated) we have 21 images on the server (src + 6 caches) on a 3 language website.
For this explanation, let's call the item that provide images to other items a "main-item", and then call the items that inherited images from the main-item a "img-inherited-item".
My proposal is the following:
1. On K2 settings, add a "main language" setting for image inheritance. Or get the main lang by checking which language is the default of the site. Any way is good.
2. On the image tab, add a "inherit image from item" button.
This button will open a popup with a list of items (same popup as we get when choosing a item for a menu, or a item for mod_k2_content, with filters, etc. If the list can come pre-filtered with the main language, all the better).
3. After the main-item is selected on the popup, the image will appear on the image box, and there will be a notification "image inherited from:" and then title, language, category tree (yes, the full category path), and ID of the main-item.
4. If possible, make the same for "image gallery" and "media" tabs, as this will also reduce workload for the admin.
5. Create a different image icon (on item list) for a "main-item", and another icon for a "img-inherited item", so people can easily identify when there is a image inheritance relationship.
6. Add a confirmation message on item deletion for "main-items", so the admin will know that his img-inherited-items will have a broken image if this main-item is deleted (but if the main-item is deleted, probably the img-inherited-items will be deleted as well, as they are related).
Apart from the deletion confirmation, this modification appears to be quite simple, from my point of view. You are just telling a K2 Item to use a cached image from other item (the "image" entry in the database will have the image value of the main item, and there will be some extra fields in the database for inheritance relationship information).
This seems very maintaineable, because it doesn't force changes on database structure (it just add some fields), or lots of additional code.
I hope this goes forward.
Thank you, and best regards.
- Adam S
missing Image folder question
Category: English K2 Community
If I upload images direct into any of these folders its works, i can see the image .
The problem is when i am uploading direct into a K2 cat, or item, the image uploads but NOT to any of the folders.? It is located in the cache see this surgefx.com/media/k2/items/cache/47e29f9fe96a1771642fb05ac8a8fd00_L.jpg
So in this case that image is on an article, that was created backend, as a new item, which i uploaded image direct to item(bypassing the main media folders/sections for K2 and JOOMLA)
Thats fine but where are the originals stored? I can not find them in any folder... so i can not reuse the same images.
I can see no way to set a folder path ? or change any settings...
Any ideas ..
Thanks
- Kannan Naidu Venugopal
[Solved] Using absolute urls for k2 item image
Category: English K2 Community
Has anyone managed to use absolute urls for all k2 item image instead of the relative url ?
Currently, its /media/images/............
I need it to be http://websitedomain/media/images/......
The way i see it at the moment is to "hack" the modals/item.php file in the component.
- Wagner Pinheiro

08 Jun 2013 14:26 Replied by Wagner Pinheiro on topic print, e-mail, comment, video icons print, e-mail, comment, video icons
Category: English K2 Community
Here is how I changed my to icons, just open your k2.js add this lines to the bottom of the code and add the path of the images you want to show instead of the text.
$K2(document).ready(function(){
$K2('.itemPrintLink span').replaceWith('<img src="/components/com_k2/images/system/imprimir.png" right="0px" width="170px" height="50px" alt="Print">');
$K2('.itemEmailLink span').replaceWith('<img src="/components/com_k2/images/system/email.png" right="175pxs" width="170px" height="50px" alt="Print">');
});
I still have one issue after I did this. I can't get rid of the dot from the module.
I know it is just a matter of adding somewhere a {list-style:none;} but all the places I've tried I got the same thing as people were talking here, it seems not to work on the .css
and I also need to show the buttons side-by-side but don't know where to change.
- fabio pajalunga
Show IPTC Information in title- and captiontext
Category: Simple Image Gallery PRO
I recently bought the pro extension because I work a lot with the K2 extension. Pretty nice extension, but something important was missing ...
IPTC support!
Very disapointing, especially if users are asking for it since 2008 - so I made it myself.
I know it's probably not the best solution but it works for me - I'm only the paying customer and normally this shouldn't be my task.
Greetings Fabio Pajalunga
Here is a short tutorial
Warning 1 You will overwrite parts of the extension - after the changes you won't be able to switch to "show generic messages" in sigpro!
Warning 2 Performing extension updates will probably overwrite the changes.
1. Open the language file located in administrator folder, we're changing the dropdown value in backend (see screen 1 below)
PATH administrator/language/en-GB/en-GB.plg_content_jw_sigpro.ini
Find this:
JW_SIGP_XML_SHOW_GENERIC_MESSAGES="Show generic messages"
JW_SIGP_XML_SHOW_GENERIC_MESSAGES="Show IPTC Headline / Description"
2. Open the PHP file with an editor, we're implementing the IPTC functionality
PATH plugins/content/jw_sigpro/jw_sigpro/includes/helper.php
Find this (~line 200):
elseif ($showcaptions == 1) { $gallery[$key]->captionTitle = JText::_('JW_SIGP_LABELS_03'); $gallery[$key]->captionDescription = JText::_('JW_SIGP_LABELS_04').' <span class="sigProPopupCaption">'.$itemTitle."</span>"; }
elseif ($showcaptions == 1) { // get title and description via iptcparse $arrSizeIPTC = getimagesize($original,$arrInfoIPTC); $arrIPTC = iptcparse($arrInfoIPTC['APP13']); if(is_array($arrIPTC)) { $arrReturnTitleIPTC = $arrIPTC['2#105'][0]; $arrReturnDescriptionIPTC = $arrIPTC['2#120'][0]; } $gallery[$key]->captionTitle = $arrReturnTitleIPTC; $gallery[$key]->captionDescription = '<span style="font-weight:bold">'.$arrReturnTitleIPTC.'</span> '.$arrReturnDescriptionIPTC; }
3. Go to the sig pro configuration in your joomla backend plugins and switch the default caption labeling to IPTC
4. enjoy your frontend!
gallery view
image-detail view
- Sander Van de Moortel
cannot add images to an existing gallery
Category: English K2 Community
Can you confirm that the Image Gallery option in a K2 Item exhibits the same behaviour on your end? I mean is this feature really built that galleries cannot easily be completed with more images?
- Peter Grube
cannot add images to an existing gallery
Category: English K2 Community
I am pretty sure all K2 versions have it's own Media Manager, check in backend components / k2 should be on the list.
I did forget to mention one thing though, for some reason the K2 Media Manager inherits its file location structure from the default Joomla Media Manager.
So open the Default Joomla Media Manager / Options
you will see the following warning text.
Changing the default 'path to files folder' to another folder than default 'images' may break your links.
The 'path to images' folder has to be the same or to a subfolder of 'path to files'.
What I recommend is copying your existing images folder to media / k2
then change the file paths
Path to files folder = media/k2
Path to images folde = media/k2/images
In that way you wont' lose any existing links.
Then if you open the K2 Media Manager you will see your Items images folder / galleries folder etc.
- william white
change K2 item images path
Category: English K2 Community
- Amy Roberts
change K2 item images path
Category: English K2 Community
As a baindaid I made a quick scheduled task that copies the contents of /media/k2/items/cache to each of the 3 slave servers respective directories and it appears to work (im still wondering if it will break because of the cache part) but this site is expected to have a pretty substantial amount of pictures over time and that seems like a silly bandaid.
Anyway to change K2 to point to a directory outside of the sites directory so that all 4 sites could share one /media/k2/items/cache directory? We never post to the 3 slave sites.
Anyone have a better way?
Thanks in advance!
- Peter Grube
User choose K2 User Group during registration
Category: English K2 Community
The only way I could achieve this functionality was by using Community Builder to handle both the Registration & Profile but although the CB is free you need to purchase either their Conditionals plugin or alternately get the third party Community Builder Profile Pro which is able to create different profile types & Registration forms.
The only drawback is that although you can select different user types during registration, & K2 adds them to your list of users, it doesn't automatically add them to your K2 User Groups. So they cannot add items until you add them manually. Which in my case is ok, because I need to approve the users anyway.
While I am at it I thought I would ask for some feedback from the Admins here, this link mentions the same problem about syncing CB & K2 but it's over 2 yrs old, I am hoping I am missing something.
One last thing in the CB Forum has suggested work around for this but my PHP skills are limited & I am getting the dreaded white screen of death.
It says around line 957 begins the function "function saveRegistration( $option )", at the end of this function, before the "}" sign insert this code (it must be a part of the function) ...
Could someone point out where exactly is the end of this function.
- etkritikonspoudon

17 Dec 2012 17:56 Replied by etkritikonspoudon on topic Original image size in item view Original image size in item view
Category: English K2 Community
Francesco wrote: Hi, you could make a little hack to item.php (administrator\components\com_k2\models\item.php) using the following changes:
For example :
//Large image
$handle->image_resize = true;
$handle->image_ratio_y = true;
$handle->image_convert = 'jpg';
$handle->jpeg_quality = $params->get('imagesQuality');
$handle->file_auto_rename = false;
$handle->file_overwrite = true;
$handle->file_new_name_body = $filename.'_L';
if (JRequest::getInt('itemImageL')) {
$imageWidth = JRequest::getInt('itemImageL');
} else {
$imageWidth = $params->get('itemImageL', '600');
}
/* Hack !
if (($handle->image_src_x) < $imageWidth) {
$imageWidth = $handle->image_src_x;
}
/ Hack end !
$handle->image_x = $imageWidth;
$handle->Process($savepath);
Was this a response towards my question?
I tried your code, but it didn't bring about any change in the behaviour of the K2 Item Images
- Francesco
Original image size in item view
Category: English K2 Community
For example :
//Large image
$handle->image_resize = true;
$handle->image_ratio_y = true;
$handle->image_convert = 'jpg';
$handle->jpeg_quality = $params->get('imagesQuality');
$handle->file_auto_rename = false;
$handle->file_overwrite = true;
$handle->file_new_name_body = $filename.'_L';
if (JRequest::getInt('itemImageL')) {
$imageWidth = JRequest::getInt('itemImageL');
} else {
$imageWidth = $params->get('itemImageL', '600');
}
/* Hack !
if (($handle->image_src_x) < $imageWidth) {
$imageWidth = $handle->image_src_x;
}
/ Hack end !
$handle->image_x = $imageWidth;
$handle->Process($savepath);
- Goh Yew Hoe
Facebook Share returning Blank Thumbnail
Category: English K2 Community
Anyway, for anyone still looking to use this code, I have modified it to be as dynamic as possible so the field values are pulled from joomla instead of a static value. Note: Make sure you check the 2nd logo path though, it's picking logo.jpg from the root image folder but you can change it yourself to read from any folder or file.
<?php $fbog =& JFactory::getDocument(); $app = JFactory::getApplication(); $facebookImage = 'image1'.$this->item->params->get('facebookImage','Small'); $opengraph_meta = ' <meta property="og:title" content="'.$this->item->title.'"/> <meta property="og:type" content="article"/> <meta property="og:url" content="'.substr(JURI::root(),0,-1).str_replace(JURI::root(true),'',$this->item->link).'"/> <meta property="og:site_name" content="'.$app->getCfg( 'sitename' ).'"/> '; if (!empty($this->item->$facebookImage)) { $opengraph_meta .= '<meta property="og:image" content="'.substr(JURI::root(),0,-1).str_replace(JURI::root(true),'',$this->item->$facebookImage).'" />'; } else { $opengraph_meta .= '<meta property="og:image" content="'.substr(JURI::root(),0,-1).'/images/logo.jpg"/>'; } $fbog->addCustomTag( $opengraph_meta ); ?>
- Phil G
Frontend item edit dialog does not open modally.
Category: English K2 Community
I have a problem where the Frontend Item Edit form opens in the whole page, thus taking over the page. This happens on Firefox, Chrome & IE. THe behavior is different if I change my template, but it's till not correct. I want to get this working with my current template.
I use GCal and I've changed it to use jquery: gcal only.
I'm testing using the beez-20 and atomic templates. I don't have any others to use.
I've searched around on here for an answer, and see that people have had similar problems. Here follows my findings:
To reproduce the problem:
In the frontend, logged in with editing rights Click "edit item"
(with beez_20 template loaded)
Expected result:
Item should open in edit mode in squeezebox modal window.
Close button should close the modal view.
Actual result:
Item opens in edit mode in full page
Close button just reloads the item in edit mode, full page.
Second test:
(with atomic template loaded)
Actual result:
Item opens in edit mode in modal window ( cool :) )
Close button just reloads the original page in the squeezebox view. ( not cool)
So does anyone have any idea what might be causing this? What should I be looking for in my template files? I've looked for the word modal in all files of both templates' folders , but there's only
/* image upload modal */ #all #upload-flash ul li a:hover, #all .item a:hover span { background:#095197; color:#fff; } #close a {text-decoration:none}
and
a.modal-button, .button2-left .blank a, .button2-left a, .button2-left div.readmore a {background:#eee; padding:4px !important; margin:0 !important; line-height:1.2em; border:solid 1px #ddd; font-weight:bold; text-decoration:none; margin-top:10px !important}
in the beez_20 template but nothing apart from that. Commenting those out did not fix the issue.
Finally hear's the header section of my page, maybe it will help to find the problem:
<head> <base href="http://caj78.fr/index.php/course/test" /> <meta http-equiv="content-type" content="text/html; charset=utf-8" /> <meta name="generator" content="Joomla! - Open Source Content Management" /> <title>Root Category</title> <link href="/templates/beez_20/favicon.ico" rel="shortcut icon" type="image/vnd.microsoft.icon" /> <link href="http://caj78.fr/index.php/component/search/?Itemid=509&format=opensearch" rel="search" title="Valider Club Athlétisme Jeunesse" type="application/opensearchdescription+xml" /> <link rel="stylesheet" href="/media/system/css/modal.css" type="text/css" /> <link rel="stylesheet" href="/components/com_k2/css/k2.css" type="text/css" /> <link rel="stylesheet" href="/plugins/content/jw_sigpro/jw_sigpro/includes/js/jquery_slimbox/css/slimbox2.css" type="text/css" /> <link rel="stylesheet" href="/plugins/content/jw_sigpro/jw_sigpro/tmpl/Artistic/css/template.css" type="text/css" media="screen" /> <link rel="stylesheet" href="/plugins/content/jw_sigpro/jw_sigpro/includes/css/print.css" type="text/css" media="print" /> <link rel="stylesheet" href="/templates/system/css/system.css" type="text/css" /> <link rel="stylesheet" href="/templates/beez_20/css/position.css" type="text/css" media="screen,projection" /> <link rel="stylesheet" href="/templates/beez_20/css/layout.css" type="text/css" media="screen,projection" /> <link rel="stylesheet" href="/templates/beez_20/css/print.css" type="text/css" media="print" /> <link rel="stylesheet" href="/templates/beez_20/css/general.css" type="text/css" /> <link rel="stylesheet" href="/templates/beez_20/css/general_mozilla.css" type="text/css" /> <link rel="stylesheet" href="/templates/beez_20/css/personal.css" type="text/css" /> <script src="/media/system/js/mootools-core.js" type="text/javascript"></script> <script src="/media/system/js/core.js" type="text/javascript"></script> <script src="/media/system/js/mootools-more.js" type="text/javascript"></script> <script src="/media/system/js/modal.js" type="text/javascript"></script> <script src="//ajax.googleapis.com/ajax/libs/jquery/1.7/jquery.min.js" type="text/javascript"></script> <script src="/components/com_k2/js/k2.js" type="text/javascript"></script> <script src="//ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js" type="text/javascript"></script> <script src="/plugins/content/jw_sigpro/jw_sigpro/includes/js/jquery_slimbox/js/slimbox2.js" type="text/javascript"></script> <script src="/plugins/content/jw_sigpro/jw_sigpro/includes/js/behaviour.js" type="text/javascript"></script> <script src="/templates/beez_20/javascript/md_stylechanger.js" type="text/javascript"></script> <script src="/templates/beez_20/javascript/hide.js" type="text/javascript"></script> <script type="text/javascript"> window.addEvent('domready', function() { SqueezeBox.initialize({}); SqueezeBox.assign($$('a.modal'), { parse: 'rel' }); }); var K2SitePath = '/'; function keepAlive() { var myAjax = new Request({method: "get", url: "index.php"}).send();} window.addEvent("domready", function(){ keepAlive.periodical(840000); }); </script> <!--[if lte IE 6]> <link href="/templates/beez_20/css/ieonly.css" rel="stylesheet" type="text/css" /> <style type="text/css"> #line { width:98% ; } .logoheader { height:200px; } #header ul.menu { display:block !important; width:98.2% ; } </style> <![endif]--> <!--[if IE 7]> <link href="/templates/beez_20/css/ie7only.css" rel="stylesheet" type="text/css" /> <![endif]--> <script type="text/javascript"> var big ='72%'; var small='53%'; var altopen='est ouvert'; var altclose='est fermé'; var bildauf='/templates/beez_20/images/plus.png'; var bildzu='/templates/beez_20/images/minus.png'; var rightopen='Ouvrir les infos'; var rightclose='Fermer les infos'; var fontSizeTitle='Taille de la police'; var bigger='Augmenter'; var reset='Réinitialiser'; var smaller='Diminuer'; var biggerTitle='Augmenter la taille'; var resetTitle='Revenir aux styles par défaut'; var smallerTitle='Réduire la taille'; </script> </head>
If anyone can point me in the right direction I will investigate further. But I'm not sure where to look. How do you know what's conflicting with what? I use FireFox with FireBug. I'm a developer (not web, not php) by day so I know call stacks and I understand js syntax.
Thanks in advance,
Phil
- Duran Keeley
Change Cache folder for different Image resizes
Category: English K2 Community
I tried editing components\com_k2\models\item.php
were i found the cache kinda referenced as
"if (JFile::exists(JPATH_ROOT.DS.'media'.DS.'k2'.DS.'items'.DS.'cache'.DS.'XS'.DS.$filename.'_XS.jpg')"
I added the ".DS.'XS'" but I really have no clue how to do this.
- iChris
Hello ! K2 Error + blank page
Category: English K2 Community
Hello,
Christian, from Belgium. I use K2 for a long time, it is the only good free tool to manage an item. Thank you!
I would contact you because I have a problem with K2.
I develop a Joomla extension that I want the system compatible with K2, because I think your brilliant concept!
Articles must be imported into K2 from an external source.
Currently, the import completes successfully but in FRONTEND, I get this error: "Fatal error: Call to undefined method K2ModelItem :: getUserProfile () in / home/www/fashion/components/com_k2/helpers/utilities.php it line 63 "and a blank page.
I use the class ". ModelItem :: save" slightly modified. (Item entire model is imported into the extension).
In the database, everything seems OK (I compared with native recording) FRONTEND but nothing works.
Could you help me and tell me what I missed please?
Thanking you in advance.
Here k2 modified class I use:
function save($front = false, $toStore)
{
$mainframe = &JFactory::getApplication();
jimport('joomla.filesystem.file');
jimport('joomla.filesystem.folder');
jimport('joomla.filesystem.archive');
require_once (JPATH_ADMINISTRATOR.DS.'components'.DS.'com_k2'.DS.'lib'.DS.'class.upload.php');
$db = &JFactory::getDBO();
$user = &JFactory::getUser();
$row = &JTable::getInstance('K2Item', 'Table');
$params = &JComponentHelper::getParams('com_k2');
$nullDate = $db->getNullDate();
define( 'K2_JVERSION', '16' );
$jpath = JPATH_SITE.DS.'components'.DS.'com_k2';
define( 'JPATH_COMPONENT', $jpath );
if (!$row->bind($toStore))
{
$mainframe->redirect('index.php?option=com_k2&view=items', $row->getError(), 'error');
}
if ($front && $row->id == NULL)
{
JLoader::register('K2HelperPermissions', JPATH_SITE.DS.'components'.DS.'com_k2'.DS.'helpers'.DS.'permissions.php');
if (!K2HelperPermissions::canAddItem($row->catid))
{
$mainframe->redirect('index.php?option=com_k2&view=item&task=add&tmpl=component', JText::_('K2_YOU_ARE_NOT_ALLOWED_TO_POST_TO_THIS_CATEGORY_SAVE_FAILED'), 'error');
}
}
($row->id) ? $isNew = false : $isNew = true;
if ($params->get('mergeEditors'))
{
$text = $row->introtext;
if ($params->get('xssFiltering'))
{
$filter = new JFilterInput( array(), array(), 1, 1, 0);
$text = $filter->clean($text);
}
$pattern = '#<hr\s+id=("|\')system-readmore("|\')\s*\/*>#i';
$tagPos = preg_match($pattern, $text);
if ($tagPos == 0)
{
$row->introtext = $text;
$row->fulltext = '';
}
else
list($row->introtext, $row->fulltext) = preg_split($pattern, $text, 2);
}
else
{
$row->introtext = JRequest::getVar('introtext', '', 'post', 'string', 2);
$row->fulltext = JRequest::getVar('fulltext', '', 'post', 'string', 2);
if ($params->get('xssFiltering'))
{
$filter = new JFilterInput( array(), array(), 1, 1, 0);
$row->introtext = $filter->clean($row->introtext);
$row->fulltext = $filter->clean($row->fulltext);
}
}
if ($row->id)
{
$datenow = &JFactory::getDate();
$row->modified = $datenow->toMySQL();
$row->modified_by = $user->get('id');
}
else
{
$row->ordering = $row->getNextOrder("catid = {$row->catid} AND trash = 0");
if ($row->featured)
$row->featured_ordering = $row->getNextOrder("featured = 1 AND trash = 0", 'featured_ordering');
}
$row->created_by = $row->created_by ? $row->created_by : $user->get('id');
if ($front)
{
$K2Permissions = &K2Permissions::getInstance();
if (!$K2Permissions->permissions->get('editAll'))
{
$row->created_by = $user->get('id');
}
}
if ($row->created && strlen(trim($row->created)) <= 10)
{
$row->created .= ' 00:00:00';
}
$config = &JFactory::getConfig();
$tzoffset = $config->getValue('config.offset');
$date = &JFactory::getDate($row->created, $tzoffset);
$row->created = $date->toMySQL();
if (strlen(trim($row->publish_up)) <= 10)
{
$row->publish_up .= ' 00:00:00';
}
$date = &JFactory::getDate($row->publish_up, $tzoffset);
$row->publish_up = $date->toMySQL();
if (trim($row->publish_down) == JText::_('K2_NEVER') || trim($row->publish_down) == '')
{
$row->publish_down = $nullDate;
}
else
{
if (strlen(trim($row->publish_down)) <= 10)
{
$row->publish_down .= ' 00:00:00';
}
$date = &JFactory::getDate($row->publish_down, $tzoffset);
$row->publish_down = $date->toMySQL();
}
$metadata = JRequest::getVar('meta', null, 'post', 'array');
if (is_array($metadata))
{
$txt = array();
foreach ($metadata as $k => $v)
{
if ($k == 'description')
{
$row->metadesc = $v;
}
elseif ($k == 'keywords')
{
$row->metakey = $v;
}
else
{
$txt[] = "$k=$v";
}
}
$row->metadata = implode("\n", $txt);
}
if (!$row->check())
{
$mainframe->redirect('index.php?option=com_k2&view=item&cid='.$row->id, $row->getError(), 'error');
}
$dispatcher = &JDispatcher::getInstance();
JPluginHelper::importPlugin('k2');
$result = $dispatcher->trigger('onBeforeK2Save', array(&$row, $isNew));
if (in_array(false, $result, true))
{
JError::raiseError(500, $row->getError());
return false;
}
//Trigger the finder before save event
$dispatcher = JDispatcher::getInstance();
JPluginHelper::importPlugin('finder');
$results = $dispatcher->trigger('onFinderBeforeSave', array('com_k2.item', $row, $isNew));
// Try to save the video if there is no need to wait for item ID
if (!JRequest::getBool('del_video'))
{
if (!isset($files))
{
if (JRequest::getVar('remoteVideo'))
{
$fileurl = JRequest::getVar('remoteVideo');
$filetype = JFile::getExt($fileurl);
$row->video = '{'.$filetype.'remote}'.$fileurl.'{/'.$filetype.'remote}';
}
if (JRequest::getVar('videoID'))
{
$provider = JRequest::getWord('videoProvider');
$videoID = JRequest::getVar('videoID');
$row->video = '{'.$provider.'}'.$videoID.'{/'.$provider.'}';
}
if (JRequest::getVar('embedVideo', '', 'post', 'string', JREQUEST_ALLOWRAW))
{
$row->video = JRequest::getVar('embedVideo', '', 'post', 'string', JREQUEST_ALLOWRAW);
}
}
}
// JoomFish! Front-end editing compatibility
if ($mainframe->isSite() && JFile::exists(JPATH_ADMINISTRATOR.DS.'components'.DS.'com_joomfish'.DS.'joomfish.php'))
{
if (version_compare(phpversion(), '5.0') < 0)
{
$tmpRow = $row;
}
else
{
$tmpRow = clone($row);
}
}
if (!$row->store())
{
$mainframe->redirect('index.php?option=com_k2&view=items', $row->getError(), 'error');
}
// JoomFish! Front-end editing compatibility
if ($mainframe->isSite() && JFile::exists(JPATH_ADMINISTRATOR.DS.'components'.DS.'com_joomfish'.DS.'joomfish.php'))
{
$itemID = $row->id;
$row = $tmpRow;
$row->id = $itemID;
}
if (!$params->get('disableCompactOrdering'))
{
$row->reorder("catid = {$row->catid} AND trash = 0");
}
if ($row->featured && !$params->get('disableCompactOrdering'))
{
$row->reorder("featured = 1 AND trash = 0", 'featured_ordering');
}
$files = JRequest::get('files');
//Image
if ((int)$params->get('imageMemoryLimit'))
{
ini_set('memory_limit', (int)$params->get('imageMemoryLimit').'M');
}
$existingImage = JRequest::getVar('existingImage');
if (($files === 0 || $existingImage) && !JRequest::getBool('del_image'))
{
if ($files === 0)
{
$image = $files;
}
else
{
$image = JPATH_SITE.DS.JPath::clean($existingImage);
}
$handle = new Upload($image);
$handle->allowed = array('image/*');
if ($handle->uploaded)
{
//Image params
$category = &JTable::getInstance('K2Category', 'Table');
$category->load($row->catid);
$cparams = new JParameter($category->params);
if ($cparams->get('inheritFrom'))
{
$masterCategoryID = $cparams->get('inheritFrom');
$query = "SELECT * FROM #__k2_categories WHERE id=".(int)$masterCategoryID;
$db->setQuery($query, 0, 1);
$masterCategory = $db->loadObject();
$cparams = new JParameter($masterCategory->params);
}
$params->merge($cparams);
//Original image
$savepath = JPATH_SITE.DS.'media'.DS.'k2'.DS.'items'.DS.'src';
$handle->image_convert = 'jpg';
$handle->jpeg_quality = 100;
$handle->file_auto_rename = false;
$handle->file_overwrite = true;
$handle->file_new_name_body = md5("Image".$row->id);
$handle->Process($savepath);
$filename = $handle->file_dst_name_body;
$savepath = JPATH_SITE.DS.'media'.DS.'k2'.DS.'items'.DS.'cache';
//XLarge image
$handle->image_resize = true;
$handle->image_ratio_y = true;
$handle->image_convert = 'jpg';
$handle->jpeg_quality = $params->get('imagesQuality');
$handle->file_auto_rename = false;
$handle->file_overwrite = true;
$handle->file_new_name_body = $filename.'_XL';
if (JRequest::getInt('itemImageXL'))
{
$imageWidth = JRequest::getInt('itemImageXL');
}
else
{
$imageWidth = $params->get('itemImageXL', '800');
}
$handle->image_x = $imageWidth;
$handle->Process($savepath);
//Large image
$handle->image_resize = true;
$handle->image_ratio_y = true;
$handle->image_convert = 'jpg';
$handle->jpeg_quality = $params->get('imagesQuality');
$handle->file_auto_rename = false;
$handle->file_overwrite = true;
$handle->file_new_name_body = $filename.'_L';
if (JRequest::getInt('itemImageL'))
{
$imageWidth = JRequest::getInt('itemImageL');
}
else
{
$imageWidth = $params->get('itemImageL', '600');
}
$handle->image_x = $imageWidth;
$handle->Process($savepath);
//Medium image
$handle->image_resize = true;
$handle->image_ratio_y = true;
$handle->image_convert = 'jpg';
$handle->jpeg_quality = $params->get('imagesQuality');
$handle->file_auto_rename = false;
$handle->file_overwrite = true;
$handle->file_new_name_body = $filename.'_M';
if (JRequest::getInt('itemImageM'))
{
$imageWidth = JRequest::getInt('itemImageM');
}
else
{
$imageWidth = $params->get('itemImageM', '400');
}
$handle->image_x = $imageWidth;
$handle->Process($savepath);
//Small image
$handle->image_resize = true;
$handle->image_ratio_y = true;
$handle->image_convert = 'jpg';
$handle->jpeg_quality = $params->get('imagesQuality');
$handle->file_auto_rename = false;
$handle->file_overwrite = true;
$handle->file_new_name_body = $filename.'_S';
if (JRequest::getInt('itemImageS'))
{
$imageWidth = JRequest::getInt('itemImageS');
}
else
{
$imageWidth = $params->get('itemImageS', '200');
}
$handle->image_x = $imageWidth;
$handle->Process($savepath);
//XSmall image
$handle->image_resize = true;
$handle->image_ratio_y = true;
$handle->image_convert = 'jpg';
$handle->jpeg_quality = $params->get('imagesQuality');
$handle->file_auto_rename = false;
$handle->file_overwrite = true;
$handle->file_new_name_body = $filename.'_XS';
if (JRequest::getInt('itemImageXS'))
{
$imageWidth = JRequest::getInt('itemImageXS');
}
else
{
$imageWidth = $params->get('itemImageXS', '100');
}
$handle->image_x = $imageWidth;
$handle->Process($savepath);
//Generic image
$handle->image_resize = true;
$handle->image_ratio_y = true;
$handle->image_convert = 'jpg';
$handle->jpeg_quality = $params->get('imagesQuality');
$handle->file_auto_rename = false;
$handle->file_overwrite = true;
$handle->file_new_name_body = $filename.'_Generic';
$imageWidth = $params->get('itemImageGeneric', '300');
$handle->image_x = $imageWidth;
$handle->Process($savepath);
if ($files === 0)
$handle->Clean();
}
else
{
$mainframe->redirect('index.php?option=com_k2&view=items', $handle->error, 'error');
}
}
if (JRequest::getBool('del_image'))
{
$current = &JTable::getInstance('K2Item', 'Table');
$current->load($row->id);
$filename = md5("Image".$current->id);
if (JFile::exists(JPATH_ROOT.DS.'media'.DS.'k2'.DS.'items'.DS.'src'.DS.$filename.'.jpg'))
{
JFile::delete(JPATH_ROOT.DS.'media'.DS.'k2'.DS.'items'.DS.'src'.DS.$filename.'.jpg');
}
if (JFile::exists(JPATH_ROOT.DS.'media'.DS.'k2'.DS.'items'.DS.'cache'.DS.$filename.'_XS.jpg'))
{
JFile::delete(JPATH_ROOT.DS.'media'.DS.'k2'.DS.'items'.DS.'cache'.DS.$filename.'_XS.jpg');
}
if (JFile::exists(JPATH_ROOT.DS.'media'.DS.'k2'.DS.'items'.DS.'cache'.DS.$filename.'_S.jpg'))
{
JFile::delete(JPATH_ROOT.DS.'media'.DS.'k2'.DS.'items'.DS.'cache'.DS.$filename.'_S.jpg');
}
if (JFile::exists(JPATH_ROOT.DS.'media'.DS.'k2'.DS.'items'.DS.'cache'.DS.$filename.'_M.jpg'))
{
JFile::delete(JPATH_ROOT.DS.'media'.DS.'k2'.DS.'items'.DS.'cache'.DS.$filename.'_M.jpg');
}
if (JFile::exists(JPATH_ROOT.DS.'media'.DS.'k2'.DS.'items'.DS.'cache'.DS.$filename.'_L.jpg'))
{
JFile::delete(JPATH_ROOT.DS.'media'.DS.'k2'.DS.'items'.DS.'cache'.DS.$filename.'_L.jpg');
}
if (JFile::exists(JPATH_ROOT.DS.'media'.DS.'k2'.DS.'items'.DS.'cache'.DS.$filename.'_XL.jpg'))
{
JFile::delete(JPATH_ROOT.DS.'media'.DS.'k2'.DS.'items'.DS.'cache'.DS.$filename.'_XL.jpg');
}
if (JFile::exists(JPATH_ROOT.DS.'media'.DS.'k2'.DS.'items'.DS.'cache'.DS.$filename.'_Generic.jpg'))
{
JFile::delete(JPATH_ROOT.DS.'media'.DS.'k2'.DS.'items'.DS.'cache'.DS.$filename.'_Generic.jpg');
}
$row->image_caption = '';
$row->image_credits = '';
}
//Attachments
$attachments = JRequest::getVar('attachment_file', NULL, 'FILES', 'array');
$attachments_names = JRequest::getVar('attachment_name', '', 'POST', 'array');
$attachments_titles = JRequest::getVar('attachment_title', '', 'POST', 'array');
$attachments_title_attributes = JRequest::getVar('attachment_title_attribute', '', 'POST', 'array');
$attachments_existing_files = JRequest::getVar('attachment_existing_file', '', 'POST', 'array');
$attachmentFiles = array();
if (count($attachments))
{
foreach ($attachments as $k => $l)
{
foreach ($l as $i => $v)
{
if (!array_key_exists($i, $attachmentFiles))
$attachmentFiles[$i] = array();
$attachmentFiles[$i][$k] = $v;
}
}
$path = $params->get('attachmentsFolder', NULL);
if (is_null($path))
{
$savepath = JPATH_ROOT.DS.'media'.DS.'k2'.DS.'attachments';
}
else
{
$savepath = $path;
}
$counter = 0;
foreach ($attachmentFiles as $key => $file)
{
if ($file["tmp_name"] || $attachments_existing_files[$key])
{
$attachmentCleanUpFlag = true;
if ($attachments_existing_files[$key])
{
$file = JPATH_SITE.DS.JPath::clean($attachments_existing_files[$key]);
$attachmentCleanUpFlag = false;
}
$handle = new Upload($file);
if ($handle->uploaded)
{
$handle->file_auto_rename = true;
$handle->allowed[] = 'application/x-zip';
$handle->allowed[] = 'application/download';
$handle->Process($savepath);
$filename = $handle->file_dst_name;
if ($attachmentCleanUpFlag)
{
$handle->Clean();
}
$attachment = &JTable::getInstance('K2Attachment', 'Table');
$attachment->itemID = $row->id;
$attachment->filename = $filename;
$attachment->title = ( empty($attachments_titles[$counter])) ? $filename : $attachments_titles[$counter];
$attachment->titleAttribute = ( empty($attachments_title_attributes[$counter])) ? $filename : $attachments_title_attributes[$counter];
$attachment->store();
}
else
{
$mainframe->redirect('index.php?option=com_k2&view=items', $handle->error, 'error');
}
}
$counter++;
}
}
//Gallery
$flickrGallery = JRequest::getVar('flickrGallery');
if ($flickrGallery)
{
$row->gallery = '{gallery}'.$flickrGallery.'{/gallery}';
}
if (isset($files) && $files == 0 && !JRequest::getBool('del_gallery'))
{
$handle = new Upload($files);
$handle->file_auto_rename = true;
$savepath = JPATH_ROOT.DS.'media'.DS.'k2'.DS.'galleries';
$handle->allowed = array("application/download", "application/rar", "application/x-rar-compressed", "application/arj", "application/gnutar", "application/x-bzip", "application/x-bzip2", "application/x-compressed", "application/x-gzip", "application/x-zip-compressed", "application/zip", "multipart/x-zip", "multipart/x-gzip", "application/x-unknown", "application/x-zip");
if ($handle->uploaded)
{
$handle->Process($savepath);
$handle->Clean();
if (JFolder::exists($savepath.DS.$row->id))
{
JFolder::delete($savepath.DS.$row->id);
}
if (!JArchive::extract($savepath.DS.$handle->file_dst_name, $savepath.DS.$row->id))
{
$mainframe->redirect('index.php?option=com_k2&view=items', JText::_('K2_GALLERY_UPLOAD_ERROR_CANNOT_EXTRACT_ARCHIVE'), 'error');
}
else
{
$row->gallery = '{gallery}'.$row->id.'{/gallery}';
}
JFile::delete($savepath.DS.$handle->file_dst_name);
$handle->Clean();
}
else
{
$mainframe->redirect('index.php?option=com_k2&view=items', $handle->error, 'error');
}
}
if (JRequest::getBool('del_gallery'))
{
$current = &JTable::getInstance('K2Item', 'Table');
$current->load($row->id);
if (JFolder::exists(JPATH_ROOT.DS.'media'.DS.'k2'.DS.'galleries'.DS.$current->id))
{
JFolder::delete(JPATH_ROOT.DS.'media'.DS.'k2'.DS.'galleries'.DS.$current->id);
}
$row->gallery = '';
}
//Video
if (!JRequest::getBool('del_video'))
{
if (isset($files) && $files == 0)
{
$videoExtensions = array("flv", "mp4", "ogv", "webm", "f4v", "m4v", "3gp", "3g2", "mov", "mpeg", "mpg", "avi", "wmv", "divx");
$audioExtensions = array("mp3", "aac", "m4a", "ogg", "wma");
$validExtensions = array_merge($videoExtensions, $audioExtensions);
$filetype = JFile::getExt($files);
if (!in_array($filetype, $validExtensions))
{
$mainframe->redirect('index.php?option=com_k2&view=items', JText::_('K2_INVALID_VIDEO_FILE'), 'error');
}
if (in_array($filetype, $videoExtensions))
{
$savepath = JPATH_ROOT.DS.'media'.DS.'k2'.DS.'videos';
}
else
{
$savepath = JPATH_ROOT.DS.'media'.DS.'k2'.DS.'audio';
}
$filename = JFile::stripExt($files);
JFile::upload($files, $savepath.DS.$row->id.'.'.$filetype);
$filetype = JFile::getExt($files);
$row->video = '{'.$filetype.'}'.$row->id.'{/'.$filetype.'}';
}
}
else
{
$current = &JTable::getInstance('K2Item', 'Table');
$current->load($row->id);
preg_match_all("#^{(.*?)}(.*?){#", $current->video, $matches, PREG_PATTERN_ORDER);
$videotype = $matches[1][0];
$videofile = $matches[2][0];
if (in_array($videotype, $videoExtensions))
{
if (JFile::exists(JPATH_ROOT.DS.'media'.DS.'k2'.DS.'videos'.DS.$videofile.'.'.$videotype))
JFile::delete(JPATH_ROOT.DS.'media'.DS.'k2'.DS.'videos'.DS.$videofile.'.'.$videotype);
}
if (in_array($videotype, $audioExtensions))
{
if (JFile::exists(JPATH_ROOT.DS.'media'.DS.'k2'.DS.'audio'.DS.$videofile.'.'.$videotype))
JFile::delete(JPATH_ROOT.DS.'media'.DS.'k2'.DS.'audio'.DS.$videofile.'.'.$videotype);
}
$row->video = '';
$row->video_caption = '';
$row->video_credits = '';
}
//Extra fields
$objects = array();
$variables = JRequest::get('post', 4);
foreach ($variables as $key => $value)
{
if (( bool )JString::stristr($key, 'K2ExtraField_'))
{
$object = new JObject;
$object->set('id', JString::substr($key, 13));
$object->set('value', $value);
unset($object->_errors);
$objects[] = $object;
}
}
$csvFiles = JRequest::get('files');
foreach ($csvFiles as $key => $file)
{
if (( bool )JString::stristr($key, 'K2ExtraField_'))
{
$object = new JObject;
$object->set('id', JString::substr($key, 13));
$csvFile = $file[0];
if (!empty($csvFile) && JFile::getExt($file[0]) == 'csv')
{
$handle = @fopen($csvFile, 'r');
$csvData = array();
while (($data = fgetcsv($handle, 1000)) !== FALSE)
{
$csvData[] = $data;
}
fclose($handle);
$object->set('value', $csvData);
}
else
{
require_once (JPATH_ADMINISTRATOR.DS.'components'.DS.'com_k2'.DS.'lib'.DS.'JSON.php');
$json = new Services_JSON;
$object->set('value', $json->decode(JRequest::getVar('K2CSV_'.$object->id)));
if (JRequest::getBool('K2ResetCSV_'.$object->id))
$object->set('value', null);
}
unset($object->_errors);
$objects[] = $object;
}
}
require_once (JPATH_ADMINISTRATOR.DS.'components'.DS.'com_k2'.DS.'lib'.DS.'JSON.php');
$json = new Services_JSON;
$row->extra_fields = $json->encode($objects);
require_once (JPATH_ADMINISTRATOR.DS.'components'.DS.'com_k2'.DS.'models'.DS.'extrafield.php');
$extraFieldModel = new K2ModelExtraField;
$row->extra_fields_search = '';
foreach ($objects as $object)
{
$row->extra_fields_search .= $extraFieldModel->getSearchValue($object->id, $object->value);
$row->extra_fields_search .= ' ';
}
//Tags
if ($user->gid < 24 && $params->get('lockTags'))
$params->set('taggingSystem', 0);
$db = &JFactory::getDBO();
$query = "DELETE FROM #__k2_tags_xref WHERE itemID={intval($row->id)}";
$db->setQuery($query);
$db->query();
if ($params->get('taggingSystem'))
{
if ($user->gid < 24 && $params->get('lockTags'))
JError::raiseError(403, JText::_('K2_ALERTNOTAUTH'));
$tags = JRequest::getVar('tags', NULL, 'POST', 'array');
if (count($tags))
{
$tags = array_unique($tags);
foreach ($tags as $tag)
{
$tag = str_replace('-', '', $tag);
$query = "SELECT id FROM #__k2_tags WHERE name=".$db->Quote($tag);
$db->setQuery($query);
$tagID = $db->loadResult();
if ($tagID)
{
$query = "INSERT INTO #__k2_tags_xref (`id`, `tagID`, `itemID`) VALUES (NULL, {intval($tagID)}, {intval($row->id)})";
$db->setQuery($query);
$db->query();
}
else
{
$K2Tag = &JTable::getInstance('K2Tag', 'Table');
$K2Tag->name = $tag;
$K2Tag->published = 1;
$K2Tag->check();
$K2Tag->store();
$query = "INSERT INTO #__k2_tags_xref (`id`, `tagID`, `itemID`) VALUES (NULL, {intval($K2Tag->id)}, {intval($row->id)})";
$db->setQuery($query);
$db->query();
}
}
}
}
else
{
$tags = JRequest::getVar('selectedTags', NULL, 'POST', 'array');
if (count($tags))
{
foreach ($tags as $tagID)
{
$query = "INSERT INTO #__k2_tags_xref (`id`, `tagID`, `itemID`) VALUES (NULL, {intval($tagID)}, {intval($row->id)})";
$db->setQuery($query);
$db->query();
}
}
}
if ($front)
{
if (!K2HelperPermissions::canPublishItem($row->catid) && $row->published)
{
$row->published = 0;
$mainframe->enqueueMessage(JText::_('K2_YOU_DONT_HAVE_THE_PERMISSION_TO_PUBLISH_ITEMS'), 'notice');
}
}
$query = "UPDATE #__k2_items SET
video_caption = ".$db->Quote($row->video_caption).",
video_credits = ".$db->Quote($row->video_credits).", ";
if (!is_null($row->video))
{
$query .= " video = ".$db->Quote($row->video).", ";
}
if (!is_null($row->gallery))
{
$query .= " gallery = ".$db->Quote($row->gallery).", ";
}
$query .= " extra_fields = ".$db->Quote($row->extra_fields).",
extra_fields_search = ".$db->Quote($row->extra_fields_search)." ,
published = ".$db->Quote($row->published)."
WHERE id = ".$row->id;
$db->setQuery($query);
if (!$db->query())
{
$mainframe->redirect('index.php?option=com_k2&view=items', $db->getErrorMsg(), 'error');
}
$row->checkin();
$cache = &JFactory::getCache('com_k2');
$cache->clean();
$dispatcher->trigger('onAfterK2Save', array(&$row, $isNew));
if (K2_JVERSION == '16')
{
$dispatcher->trigger('onContentAfterSave', array(&$row, $isNew));
}
else
{
$dispatcher->trigger('onAfterContentSave', array(&$row, $isNew));
}
//Trigger the finder after save event
$dispatcher = JDispatcher::getInstance();
JPluginHelper::importPlugin('finder');
$results = $dispatcher->trigger('onFinderAfterSave', array('com_k2.item', $row, $isNew));
switch (JRequest::getCmd('task'))
{
case 'apply' :
$msg = JText::_('K2_CHANGES_TO_ITEM_SAVED');
$link = 'index.php?option=com_k2&view=item&cid='.$row->id;
break;
case 'saveAndNew' :
$msg = JText::_('K2_ITEM_SAVED');
$link = 'index.php?option=com_k2&view=item';
break;
case 'save' :
default :
$msg = JText::_('K2_ITEM_SAVED');
if ($front)
$link = 'index.php?option=com_k2&view=item&task=edit&cid='.$row->id.'&tmpl=component&Itemid='.JRequest::getInt('Itemid');
else
$link = 'index.php?option=com_k2&view=items';
break;
}
return $row->id;
}
- kmfabercreative
Local audio won't load / play
Category: AllVideos
Okay, so I had installed k2 v.2.5.7 & allvideo v.4.4 to use for media provision on a new site. However, I couldn't get the audio that we needed to play (local mp3 via FTP to the "images/audio" folder that we created), for whatever reason.
Allvideos plugin parameters for audio were set appropriately (local folder was set to "images/audio") but nothing was working (couldn't even get the tags to work in content).
So, I started to do some looking. First, I did a complete manual upload via the media upload function within a k2 item (25MB, it took a bit). This, I found, ended up placing the file in the "media" folder (media/k2/audio), which was a bit odd. So, I dug a bit further.
I looked into the plugins php files (specifically, jw_allvideos.php) and noticed that the audio parameters that were hardcoded were set to ('afolder','images/stories/audio'). Upon changing the (images/stories/audio) path to "images/audio", or removing it completely, my problems were solved. So, it appears this hardcoded parameter was overriding the settings in the plugin.
I have tested this minimally (I removed the path completely and changed the folder in the parameters to something other than "images/audio", created the new folder and uploaded some media to it, then called it in an item and it worked), but I think this may be the root of my issue.
I hope that if others are finding issues such as mine, this may help them out. For moderators / admins of this category, any thoughts or insights? Can you validate what I've said (or not)?
Cheers
kmfabercreative
- evangelyn
AllVideo with K2 (Local video folder)
Category: English K2 Community
Joomla's media manager is currently pointing to "images" and users have been uploading files to that folder. I don't wise to change the media manager path to "media" even though that enables users to upload the video to the correct path. Is there any way to ensure that the video path reads for the plugin parameter?
AllVideos plugin V4.4
K2 version 2.5.4
- Uldis
Images disappearing from media manager
Category: English K2 Community
I changed path in Joomla media manager like this:
Path to files folder - media/k2/images
Path to images folder - media/k2/images
When I try to upload image in k2 item media manager find new path as it should
But when I insert image I get this path instead of "media/k2/images"
And when I try to save I get this error
- evangelyn
AllVideo with K2 (Local video folder does not follow allvideos plugin parameter)
Category: AllVideos
Joomla's media manager is currently pointing to "images" and users have been uploading files to that folder. I don't wise to change the media manager path to "media" even though that enables users to upload the video to the correct path. Is there any way to ensure that the video path reads for the plugin parameter?
AllVideos plugin V4.4
K2 version 2.5.4