Port of ImageCache Profiles to D6

zilla - February 23, 2008 - 19:04
Project:ImageCache Profiles
Version:5.x-1.4
Component:Code
Category:feature request
Priority:normal
Assigned:Unassigned
Status:patch (code needs review)
Description

brilliant module, followed that whole thread earlier (http://drupal.org/node/59151)

any idea if this is going to make it to drupal 6? i'm happy to test for you as soon as it's there...just drop me a note via contact

#1

v1nce - April 1, 2008 - 13:11

Yes. I will port to D6 and add new functionality when time permits. Currently, I don't have time to commit to this module yet.

#2

flickerfly - June 19, 2008 - 21:17
Title:port to d6?» Port of ImageCache Profiles to D6

I'll also be interested in testing out the D6 version.

#3

mariusooms - July 17, 2008 - 18:33

I have almost ported it and it's very close to working. I need help porting these two original functions:

<?php
/**
* Additional form validation for the user_edit form
*/
function imagecache_profiles_user_edit_validate($form_id, $form_values) {
 
// Add a minimum size requirement to the image upload form
 
if ($info = file_check_upload('picture_upload')) {
   
$image_info = image_get_info($form_values['picture']);
    if (
$image_info['width'] < variable_get('user_picture_imagecache_profiles_min_width', 0) || $image_info['height'] < variable_get('user_picture_imagecache_profiles_min_height', 0)) {
     
form_set_error('picture_upload',t('The image must be at least @min_user_picture_width pixels wide and @min_user_picture_height pixels tall (your image was @width x @height pixels).',array('@min_user_picture_width' => check_plain(variable_get('user_picture_imagecache_profiles_min_width', 0)), '@min_user_picture_height' => check_plain(variable_get('user_picture_imagecache_profiles_min_height', 0)), '@width' => $image_info['width'], '@height' => $image_info['height'])));
    }
  }
}

/**
* Check for new or deleted uploads and clear the imagecache if necessary
*/
function imagecache_profiles_user_edit_submit($form_id, $form_values) {
  if (
file_check_upload('picture_upload') || $form_values['picture_delete']) {
   
imagecache_image_flush($form_values['picture']);
  }
}
?>

I believe other than these everything will work. The validation and flushing is just not working correctly.

This is what I made of the functions, maybe someone can see what I missed or did wrong:

<?php
/**
* Additional form validation for the user_edit form
*/
function imagecache_profiles_user_edit_validate($form, &$form_state) {
 
// Add a minimum size requirement to the image upload form
 
if ($info = file_safe_upload('picture_upload')) {
   
$image_info = image_get_info($form_state['values']['picture']);
    if (
$image_info['width'] < variable_get('user_picture_imagecache_profiles_min_width', 0) || $image_info['height'] < variable_get('user_picture_imagecache_profiles_min_height', 0)) {
     
form_set_error('picture_upload', t('The image must be at least @min_user_picture_width pixels wide and @min_user_picture_height pixels tall (your image was @width x @height pixels).', array('@min_user_picture_width' => check_plain(variable_get('user_picture_imagecache_profiles_min_width', 0)), '@min_user_picture_height' => check_plain(variable_get('user_picture_imagecache_profiles_min_height', 0)), '@width' => $image_info['width'], '@height' => $image_info['height'])));
    }
  }
}

/**
* Check for new or deleted uploads and clear the imagecache if necessary
*/
function imagecache_profiles_user_edit_submit($form, &$form_state) {
  if (
file_safe_upload('picture_upload') || $form_state['values']['picture_delete']) {
   
imagecache_image_flush($form_state['values']['picture']);
  }
}
?>

Any help is appreciated.

#4

mariusooms - July 17, 2008 - 18:46

Attached is the complete ported code I have so far. I'm new at this so if I do something wrong, don't hesitate to correct me.

Regards,

Marius

AttachmentSize
imagecache_profiles-dp6.zip9.86 KB

#5

mariusooms - July 17, 2008 - 22:56

Well...I have tried and failed...I thought I was close, but it looks like I will have to wait until someone with more knowledge than me can port this over as I am just stuck. Hopefully the maintainer will find some time to do a proper port.

Regards,

Marius

#6

wuf31 - July 18, 2008 - 10:51
Status:active» patch (code needs review)

Well.. building on Marius work, this is a d6 version that is working, at least for me.

Still, a word of warning, it needs much more detailed review, i only make marius' code work, at least from the user side. Don't have time yet to delve in further, yet it could be a base ground work.

Review please..

Thanks,
Jhon

AttachmentSize
imagecache_profiles.zip8.82 KB

#7

mariusooms - July 18, 2008 - 12:37

Terima Kasi Jhon! I knew I was close, just this line huh: 'html' => TRUE

I wish coder could pick that stuff up. I realize I should submit a patch, but I don't know how to create those yet. Indeed, this is just a hard code port of the version 5 branch, using coder. Use at your own risk ;)

Regards,

Marius

PS-Jhon. Istri saya orang indonesia!

#8

wuf31 - July 21, 2008 - 14:23

Sama2 marius, nice work here :)

Yep, just change one line and you're ready to go.
To create patches, you can take a look at http://drupal.org/patch/create.

Regards,

Jhon

PS-Marius. Glad you like Indonesian's women :P

#9

THOOR - August 17, 2008 - 17:16

Hi there ...

Thanks for the module. I am using it at D 6.4 and its working fine together with ImageCache. But I am having a small problem.
The default Picture for users without a uploaded image is not shown. Any ideas for me?

#10

mariusooms - August 18, 2008 - 07:50

What path for the default image do you have specified in the admin user settings?

You could check the source code and see if the image path is malformed. I had that happen and I just needed to adjust the path.

Regards,

Marius

#11

mariusooms - August 18, 2008 - 07:55

Currently what is not working with this version yet is the flushing of the original uploaded image. Also the code provided here, should only be used for testing purposes or if you are desperate to get imagecache profiles working right away. Definitely not for production site and I think the maintainer will create a far superior port for Drupal 6.

Regards,

Marius

#12

THOOR - August 18, 2008 - 13:14

Hi Marius,

Thanx! You where right! Just a matter of the path to the deafault image! Its working :-)

#13

Chippe - August 26, 2008 - 18:36

Great work Marius!

Hopefully it won't take too long until somebody finds a solution to the flush function.
Manual flush in the imagecache menu deletes the pictures but it gives me this error: [function.rmdir]: Permission denied
..imagecache.module on line 695
I don't know if it's just on my site or if the imagecache_profile flushing problem has anything to do with this.

#14

mariusooms - August 28, 2008 - 19:08

Okay...so I tried a manual flush, but now profile images don't want to show at all! I didn't receive the Permission denied error.

#15

Chippe - August 28, 2008 - 21:12

This was not after flushing but at one time imagecache didn't create pictures until I disabled clean-urls. After that I could have it enabled again.

Btw. I think my problem is related to xampp.

#16

marcingy - August 29, 2008 - 00:15
Version:5.x-1.3» 5.x-1.4

Patch rolled against current release version which seems to fix the cache issue as the appropriate functions are now being called.

AttachmentSize
imagecache_profiles.patch7.02 KB

#17

japanitrat - August 29, 2008 - 01:47

subscribe

#18

Chippe - August 29, 2008 - 20:53

First time I patch but I downloaded patch.exe and placed it in the imagecache_profiles folder.
In command prompt: patch -p0 < imagecache_profiles_0.patch

It gives me this error:

missing header for unified diff at line 39 of patch
can't find file to patch at input line 39
Perhaps you used the wrong -p or --strip option?
The text leading up to this was:
--------------------------
| +57,7 @@
|
| if (isset($picture)) {
| if (!empty($account->uid) && user_access('access user profiles')) {
|- $picture = l($picture, "user/$account->uid", array('title' => t('View
user profile.')), NULL, NULL, FALSE, TRUE);
|+ $picture = l($picture, "user/$account->uid", array('title' => t('View
user profile.'), 'html' => TRUE));
| }
|
| return ''. $picture .'';
--------------------------

Edit: I manually replaced some lines and now it works perfect for me.
Thank you Marcingy

#19

mariusooms - August 29, 2008 - 22:40

Patch worked great for me (patched on Mac with terminal) and indeed fixed the imagecache_profiles flush...thanks marcingy, much appreciate your help with this and creating a proper patch!

Regards,

Marius

#20

chinafka - September 2, 2008 - 22:12

Could someone post the patched version? I've been messing around with this for a few hours trying to get eclipse and the synchronization working to patch it and it's just not doing it for me. Are there any easier ways to apply a patch to a file? From the relative stance that I don't know much on how to do this.

#21

mariusooms - September 3, 2008 - 07:09

Make sure you patch against 5.x-1.4, both the module and info file.

For windows you could try using Cygwin instead

http://drupal.org/node/32875

#22

andypost - September 5, 2008 - 00:03

#6 Works fine for me!

#23

chinafka - September 5, 2008 - 22:49

Seems like it's working for everyone else so I'll give cygwin a try, thanks.

 
 

Drupal is a registered trademark of Dries Buytaert.