Keyword

K2 image upload: hide K2_IMAGE_WAS_NOT_UPLOADED notice

  • Szymon Pluta
  • Szymon Pluta's Avatar Topic Author
  • Offline
  • Junior Member
More
8 years 1 week ago - 8 years 1 week ago #161388 by Szymon Pluta
Hi,

I noticed that when I save article on front end with turned off (k2 settings) or removed images tab Jooomla show K2_IMAGE_WAS_NOT_UPLOADED notice.

I could modify save() function in com_k2 (just add
if(!empty($image))
inside image upload part, but I would rather avoid that.

How to fix it without overriding core file?

Please don't say "make image input file display: none".

http://imgur.com/a/AACQI
Last edit: 8 years 1 week ago by Szymon Pluta.

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

  • Krikor Boghossian
  • Krikor Boghossian's Avatar
  • Offline
  • Platinum Member
More
8 years 1 week ago #161399 by Krikor Boghossian
Replied by Krikor Boghossian on topic K2 image upload: hide K2_IMAGE_WAS_NOT_UPLOADED notice
Hello,

The image is not by default required.
Are you using any 3rd party extensions?

JoomlaWorks Support Team
---
Please search the forum before posting a new topic :)

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

  • Szymon Pluta
  • Szymon Pluta's Avatar Topic Author
  • Offline
  • Junior Member
More
8 years 1 week ago #161407 by Szymon Pluta
I turned off all additional extensions and disabled front-end image tab in k2 settings. Save() function still try to get $image element and with disabled image tab error show. The only solution I found out is to add if(!empty($image)) check.

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

  • Krikor Boghossian
  • Krikor Boghossian's Avatar
  • Offline
  • Platinum Member
More
8 years 1 week ago #161409 by Krikor Boghossian
Replied by Krikor Boghossian on topic K2 image upload: hide K2_IMAGE_WAS_NOT_UPLOADED notice
Which version of K2 are you using?
If I can replicate it then I will add your edit in the repo.

JoomlaWorks Support Team
---
Please search the forum before posting a new topic :)

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

  • Szymon Pluta
  • Szymon Pluta's Avatar Topic Author
  • Offline
  • Junior Member
More
8 years 1 week ago #161412 by Szymon Pluta
I'm using k2 v2.7.1.

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

  • Krikor Boghossian
  • Krikor Boghossian's Avatar
  • Offline
  • Platinum Member
More
8 years 1 day ago #161491 by Krikor Boghossian
Replied by Krikor Boghossian on topic K2 image upload: hide K2_IMAGE_WAS_NOT_UPLOADED notice
Can you send me your edit?

JoomlaWorks Support Team
---
Please search the forum before posting a new topic :)

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

  • Szymon Pluta
  • Szymon Pluta's Avatar Topic Author
  • Offline
  • Junior Member
More
8 years 1 day ago #161508 by Szymon Pluta
There you Go.
location: administrator/components/com_k2/models/item.php line 276
		if (($files['image']['error'] == 0 || $existingImage) && !JRequest::getBool('del_image'))
		{
            if (!empty($image)){   //added check if $image is empty 
                if ($files['image']['error'] == 0)
                {
                    $image = $files['image'];
                }
                else
                {
                    $image = JPATH_SITE.DS.JPath::clean($existingImage);
                }

                $handle = new Upload($image);
                $handle->allowed = array('image/*');
                $handle->forbidden = array('image/tiff');

                if ($handle->file_is_image && $handle->uploaded)
                {
                    //Image params
                    $category = JTable::getInstance('K2Category', 'Table');
                    $category->load($row->catid);
                    $cparams = class_exists('JParameter') ? new JParameter($category->params) : new JRegistry($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 = class_exists('JParameter') ? new JParameter($masterCategory->params) : new JRegistry($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['image']['error'] == 0)
                        $handle->Clean();

                }
                else
                {
                    $mainframe->enqueueMessage(JText::_('K2_IMAGE_WAS_NOT_UPLOADED'), 'notice');
                }
            }// end check if $image is empty 
		}

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

  • Krikor Boghossian
  • Krikor Boghossian's Avatar
  • Offline
  • Platinum Member
More
8 years 1 day ago #161516 by Krikor Boghossian
Replied by Krikor Boghossian on topic K2 image upload: hide K2_IMAGE_WAS_NOT_UPLOADED notice
Thanks Buddy :)

JoomlaWorks Support Team
---
Please search the forum before posting a new topic :)

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

More
7 years 6 months ago #164617 by lcemk
Hello guys,

I'm having a similar issue also with 2.7.1 version.

I check the code Szymon Pluta leave it here but iam not sure what to update. After line 276 should i replace evrything for his code?

Thanks

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

  • Krikor Boghossian
  • Krikor Boghossian's Avatar
  • Offline
  • Platinum Member
More
7 years 6 months ago #164627 by Krikor Boghossian
Replied by Krikor Boghossian on topic K2 image upload: hide K2_IMAGE_WAS_NOT_UPLOADED notice
Can you try updating to 2.8?

JoomlaWorks Support Team
---
Please search the forum before posting a new topic :)

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

  • Szymon Pluta
  • Szymon Pluta's Avatar Topic Author
  • Offline
  • Junior Member
More
7 years 6 months ago #164630 by Szymon Pluta
Hi guys,

if you ant to add my fix to file :

1. find line
if (($files['image']['error'] == 0 || $existingImage) && !JRequest::getBool('del_image'))
		{

2. insert there
 if (!empty($image)){   //added check if $image is empty 


3 find
       else
                {
                    $mainframe->enqueueMessage(JText::_('K2_IMAGE_WAS_NOT_UPLOADED'), 'notice');
                }

4. put
 }// end check if $image is empty 

All other elements are from original file.

You can also try to check it with WinMerge.

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


Powered by Kunena Forum