Keyword

Content Module Image resizing

More
15 years 1 month ago #71584 by Gerard Croteau
Replied by Gerard Croteau on topic Content Module Image resizing
Fellow K2 adepts and friends

I'm happy that some of you shared their ideas about this problem. After a while, I tought it could be an incompatibility with a template. I tried with several templates. No way, K2 still not resizing any images. Do I have to understand that a PHP GD library has to be installed on the server ? I don't know that stuff, I'm a end user. Should I ask to my hoster to invest time to let me use K2 ?

For me, even I like K2, the fact that I can't resize any images, whatever the setup I use in the setup panels, is really anoying. I hope to get a solution soon, as we have to make a final decision to use or not K2, and look for an alternative. I'm sad as I invested serveral hours to learn it and I would'nt like to start a new process.

K2 refuse to resize any images. That's all ! whatever I played with all the possible set up options. Thank you for your ideas and help.

Richard Pigden said:Hi Lefteris
I think this is just a case of me being an idiot! I had made the assumption K2 would resize any image added within the Item text but of course that is not the case - it will only resize the image that you upload via the Image tab, and that works perfectly!

My apologies for not realising this sooner and wasting your time.

Richard

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

More
15 years 1 month ago #71585 by Rune Christensen
Replied by Rune Christensen on topic Content Module Image resizing
I had this problem and switching back to php 5.2 from 5.3 did the job!

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

More
15 years 1 month ago #71586 by Lefteris
Replied by Lefteris on topic Content Module Image resizing
Hi. K2 has some system requirements. A quick way to check things is to click on the "Information" tab on K2 administration.

Gerard Croteau said:Fellow K2 adepts and friends
I'm happy that some of you shared their ideas about this problem. After a while, I tought it could be an incompatibility with a template. I tried with several templates. No way, K2 still not resizing any images. Do I have to understand that a PHP GD library has to be installed on the server ? I don't know that stuff, I'm a end user. Should I ask to my hoster to invest time to let me use K2 ?

For me, even I like K2, the fact that I can't resize any images, whatever the setup I use in the setup panels, is really anoying. I hope to get a solution soon, as we have to make a final decision to use or not K2, and look for an alternative. I'm sad as I invested serveral hours to learn it and I would'nt like to start a new process.

K2 refuse to resize any images. That's all ! whatever I played with all the possible set up options. Thank you for your ideas and help.

Richard Pigden said:Hi Lefteris I think this is just a case of me being an idiot! I had made the assumption K2 would resize any image added within the Item text but of course that is not the case - it will only resize the image that you upload via the Image tab, and that works perfectly!

My apologies for not realising this sooner and wasting your time.

Richard

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

More
15 years 1 month ago #71587 by Gerard Croteau
Replied by Gerard Croteau on topic Content Module Image resizing
I use PHP 5.2.9 and my web hoster won't go back to 5.2
I still have the same problem and I have to consider other tools than K2 as this bog don't let me edit adequalty my blog


Rune Christensen said:I had this problem and switching back to php 5.2 from 5.3 did the job!

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

More
15 years 1 month ago #71588 by Gerard Croteau
Replied by Gerard Croteau on topic Content Module Image resizing
When I start that question, I was looking for help. I realize that we all share the same problem but we still don't have a solution. I'm sorry as K2 appears to me as a great module. I hope that the non rezising bog will be solve. For my part, I can't do it, as I'm an end user, I don't know computer code

Thank you for your help

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

  • Nick Texidor
  • Nick Texidor's Avatar
  • Visitor
14 years 9 months ago #71589 by Nick Texidor
Replied by Nick Texidor on topic Content Module Image resizing
K2 DEVELOPERS - SOLUTION to upload/mime-type problems... and maybe the missing prefix too!

Hi all, I'm going to post this here in the hopes that the K2 developers can incorporate this into K2, but also in the hopes others will find my solution. I've also emailed the developer of class.upload.php in the hopes he can fix the error.

I've been having problems with images being uploaded and resized by the class.upload.php script that K2 uses. I've experienced the problem with the file prefixes missing, and I've run into problems within my own extensions where images need to be resized, but fails because PECL reports the MIME type as audio/x-mod.

After pulling the whole process apart, there is a fairly 'fundamental' problem with class.upload.php (v0.29 as used by K2 2.3): The init function is called after you start the upload. Therefore, any parameters you set, required by the upload function, are re-initialised.

I fixed this as follows:

In the class.upload.php file, head down to where you see:

function upload($file, $lang = 'en_GB') {

$this->version = '0.29';

$this->file_src_name = '';
$this->file_src_name_body = '';
$this->file_src_name_ext = '';
$this->file_src_mime = '';
$this->file_src_size = '';
$this->file_src_error = '';
$this->file_src_pathname = '';
$this->file_src_temp = '';

$this->file_dst_path = '';
$this->file_dst_name = '';
$this->file_dst_name_body = '';
$this->file_dst_name_ext = '';
$this->file_dst_pathname = '';

$this->image_src_x = null;
$this->image_src_y = null;
$this->image_src_bits = null;
$this->image_src_type = null;
$this->image_src_pixels = null;
$this->image_dst_x = 0;
$this->image_dst_y = 0;

$this->uploaded = true;
$this->no_upload_check = false;
$this->processed = true;
$this->error = '';
$this->log = '';
$this->allowed = array();
$this->forbidden = array();
$this->file_is_image = false;

$this->init();
$info = null;
$mime_from_browser = null;

etc.....

and change it to this:


function __construct() {
$this->version = '0.29';

$this->file_src_name = '';
$this->file_src_name_body = '';
$this->file_src_name_ext = '';
$this->file_src_mime = '';
$this->file_src_size = '';
$this->file_src_error = '';
$this->file_src_pathname = '';
$this->file_src_temp = '';

$this->file_dst_path = '';
$this->file_dst_name = '';
$this->file_dst_name_body = '';
$this->file_dst_name_ext = '';
$this->file_dst_pathname = '';

$this->image_src_x = null;
$this->image_src_y = null;
$this->image_src_bits = null;
$this->image_src_type = null;
$this->image_src_pixels = null;
$this->image_dst_x = 0;
$this->image_dst_y = 0;

$this->uploaded = true;
$this->no_upload_check = false;
$this->processed = true;
$this->error = '';
$this->log = '';
$this->allowed = array();
$this->forbidden = array();
$this->file_is_image = false;

$this->init();
}

function doUpload($file, $lang = 'en_GB') {

$info = null;
$mime_from_browser = null;
etc....

Then in your joomla extension/K2 code, you make a slight modification, change:

$handle->upload($file);

to

$handle = new upload();
$handle->doUpload($file);

Now, if you have MIME problems thanks to PECL, you can disable it with:

$handle = new upload();
$handle->mime_fileinfo = false;
$handle->doUpload($file);

I've just tried all this code, and my images are now resizing correctly.

I've attached my 'fixed' file to this message, just search for NICKS FIX to see where the code has been changed & repaired.

Hope this helps

Regards
Nick

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

More
14 years 9 months ago #71590 by Mongo
Replied by Mongo on topic Content Module Image resizing
Wow You Are The Man!!

Thank you dude I just thought people just saying I was crazy was true!.. I mean I hide it well but hehe.. But thank you for looking into such an old thread. I really appreciate it and i'm now using your file.

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

  • Nick Texidor
  • Nick Texidor's Avatar
  • Visitor
14 years 9 months ago #71591 by Nick Texidor
Replied by Nick Texidor on topic Content Module Image resizing
You're welcome Mongo. So it's resolved the issues you were having ok??

I heard back from Colin, who pretty much replied with "your fix isn't backward compatible with PHP4", gee.. all that work and that's the response??

Anyway, to make it backward compatible with PHP4, if anyone is still running it... simply change __construct to upload and you should be fine. Personally, I reckon you've got more issues than this if you're still running php4 :^)

All the best
N


Mongo said:Wow You Are The Man!!
Thank you dude I just thought people just saying I was crazy was true!.. I mean I hide it well but hehe.. But thank you for looking into such an old thread. I really appreciate it and i'm now using your file.

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

  • Nick Texidor
  • Nick Texidor's Avatar
  • Visitor
14 years 9 months ago #71592 by Nick Texidor
Replied by Nick Texidor on topic Content Module Image resizing
Hey Mongo, sorry to send yet another message. I forgot to mention that there are 4 files in K2 that need changing if you want them all to work properly:

/administrator/components/com_k2/models/category.php
/administrator/components/com_k2/models/item.php
/administrator/components/com_k2/models/user.php
/plugins/user/k2.php

In those files, simply replace all occurrences of:

$handle = new Upload($file);

with:

$handle = new upload();
$handle->mime_fileinfo = false;
$handle->doUpload($file);

and everything should be sweet! :^)



Mongo said:Wow You Are The Man!!
Thank you dude I just thought people just saying I was crazy was true!.. I mean I hide it well but hehe.. But thank you for looking into such an old thread. I really appreciate it and i'm now using your file.

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

More
14 years 9 months ago #71593 by Mongo
Replied by Mongo on topic Content Module Image resizing
Yup, I figured that by looking at your code so I went on and changed them too. I can't give any details on PHP4 I'm on PHP5+. I feel it's every designers obligation to keep PHP and MYSQL up to-date. Otherwise coders will be spending time on backward compatibility when they could have fixed or made an advancement to the current project.

But yes your code is working fine with no issues, and I really appreciate it

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

More
14 years 9 months ago #71594 by Joackim Devaud
Replied by Joackim Devaud on topic Content Module Image resizing
Hello Nick,

First, thank you for your solution... ;-)

I've changed all the line in all the files and i still have an error "file error, please try again"...
Could you upload all the files you've changed? It will be very usefull for me...

Thx for your answer...

Best Regards

Nick Texidor said:Hey Mongo, sorry to send yet another message. I forgot to mention that there are 4 files in K2 that need changing if you want them all to work properly:
/administrator/components/com_k2/models/category.php
/administrator/components/com_k2/models/item.php
/administrator/components/com_k2/models/user.php
/plugins/user/k2.php

In those files, simply replace all occurrences of:

$handle = new Upload($file);

with:

$handle = new upload();
$handle->mime_fileinfo = false;
$handle->doUpload($file);

and everything should be sweet! :^)



Mongo said:Wow You Are The Man!! Thank you dude I just thought people just saying I was crazy was true!.. I mean I hide it well but hehe.. But thank you for looking into such an old thread. I really appreciate it and i'm now using your file.

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

  • Nick Texidor
  • Nick Texidor's Avatar
  • Visitor
14 years 9 months ago #71595 by Nick Texidor
Replied by Nick Texidor on topic Content Module Image resizing
Hi Joackim,

I guess the first thing to do is actually check that your error is related to the MIME type checking. Looking at the error message you mentioned, and going through the uploader class code, It looks like the error is more related to the upload of the file.

Anyway, there is some debug code in the upload class that may help out. Which section are you uploading from? If it's adding an image to a K2 item, then open the /administrator/components/com_k2/models/item.php file. Search for $handle, and it should take you down to the code that fires off the upload script. Just before the if ($handle->uploaded) check, try putting in echo $handle->log and see if there are any helpful messages there.

If you're still having problems, send me a private message and we can take this private to try and help you out.

All the best
Nick



Joackim Devaud said:Hello Nick,
First, thank you for your solution... ;-)

I've changed all the line in all the files and i still have an error "file error, please try again"...
Could you upload all the files you've changed? It will be very usefull for me...

Thx for your answer...

Best Regards

Nick Texidor said:Hey Mongo, sorry to send yet another message. I forgot to mention that there are 4 files in K2 that need changing if you want them all to work properly: /administrator/components/com_k2/models/category.php
/administrator/components/com_k2/models/item.php
/administrator/components/com_k2/models/user.php
/plugins/user/k2.php

In those files, simply replace all occurrences of:

$handle = new Upload($file);

with:

$handle = new upload();
$handle->mime_fileinfo = false;
$handle->doUpload($file);

and everything should be sweet! :^)



Mongo said:Wow You Are The Man!! Thank you dude I just thought people just saying I was crazy was true!.. I mean I hide it well but hehe.. But thank you for looking into such an old thread. I really appreciate it and i'm now using your file.

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

More
14 years 8 months ago #71596 by Joackim Devaud
Replied by Joackim Devaud on topic Content Module Image resizing
Hello Nick,

Thank you for your fast answer.
I've tried to add echo $handle->log but nothing appears... no error and i still can't upload any images...
Do you have an id?

I'm on a french joomla 1.15.20 with K2 2.3

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

  • Nick Texidor
  • Nick Texidor's Avatar
  • Visitor
14 years 8 months ago #71597 by Nick Texidor
Replied by Nick Texidor on topic Content Module Image resizing
Hi Joackim,

The error you mentioned, 'File error. Please try again.' only appears in two places in the upload class. They both appear just after the check to see if a valid file has been passed to the routine. My fixes, previously mentioned, really only apply to the MIME type checking which is done later in the script. So I'm not sure the changes I made are going to help here. I guess the first thing we need to do is work out at which call to the upload class it fails. Could you confirm this happens when you add an image to the K2 item via the back-end? Or is it happening somewhere else? What is the filename you are entering? Does it happen to contain any odd characters, spaces maybe?

It's going to be quite hard to debug this via the forum, so if you'd like a bit of help, then lets take this off to private messages or email, and go from there?

All the best
Nick


Joackim Devaud said:Hello Nick,
Thank you for your fast answer.
I've tried to add echo $handle->log but nothing appears... no error and i still can't upload any images...
Do you have an id?

I'm on a french joomla 1.15.20 with K2 2.3

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

More
14 years 8 months ago #71598 by Joackim Devaud
Replied by Joackim Devaud on topic Content Module Image resizing
did you received my private messages?

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


Powered by Kunena Forum