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

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

v1nce’s picture

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.

flickerfly’s picture

Title: port to d6? » Port of ImageCache Profiles to D6

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

mariusooms’s picture

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.

mariusooms’s picture

FileSize
9.86 KB

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

mariusooms’s picture

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

wuf31’s picture

Status: Active » Needs review
FileSize
8.82 KB

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

mariusooms’s picture

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!

wuf31’s picture

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

Thoor’s picture

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?

mariusooms’s picture

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

mariusooms’s picture

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

Thoor’s picture

Hi Marius,

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

Chippe’s picture

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.

mariusooms’s picture

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.

Chippe’s picture

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.

marcingy’s picture

Version: 5.x-1.3 » 5.x-1.4
FileSize
7.02 KB

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

japanitrat’s picture

subscribe

Chippe’s picture

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

mariusooms’s picture

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

chinafka’s picture

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.

mariusooms’s picture

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

andypost’s picture

#6 Works fine for me!

chinafka’s picture

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

zanforlin’s picture

This path works for everyone? It has the default image and the flush thing ok?

Thank's
Leo

zanforlin’s picture

Oh, one more thing... how can i download the full version? Could someone post the patched version? (2x)

mariusooms’s picture

Category: feature » task
Status: Needs review » Patch (to be ported)

I think it is generally a bad idea to post patched modules, since the maintainer needs to remain in control of which versions are offered. There is a certain process involved. However the maintainer does seem very busy.

I think the patch is good enough to be committed into a dp 6 branch. I'm changing this patch status since, a few here have already had good results with the latest patch. Hopefully that will speed up things.

Regards,

Marius

zanforlin’s picture

Marius, thank you for your reply. Can you put here the candidate of drupal 6 imagecache profiles? I need to use this module and can help with some tests.

Before find this post here, I made a version of imagecache profile (based on the lullabots tutorial), but the default piture only work with a bad code of mine (put 'Only local images are allowed.') and the imagecache flush doesn´t work at all.

So, please, can you put the entire module here?

Thanks a lot.
Leo

mariusooms’s picture

You can just apply the latest attached patch to the latest downloadable dev. Patching is not that hard to learn and should be good practice when helping with testing and venturing in the unkowns of unofficial module code.

This link should get you going: http://drupal.org/patch/apply

Regards,

Marius

PS. It is just not good practice to attach module in the issue queue, I'm sorry I can't help you there.

marcingy’s picture

Status: Patch (to be ported) » Reviewed & tested by the community

status changed to correct status

zanforlin’s picture

It really works fine. I adjust the path to files/picture.PNG and now it works...

Junro’s picture

Hello,

Anybody could create the module for D6 with the patch? Is it hard to create?
It will be usefull for everybody who are not familiar with patches...

Subscribe! lol

etaroza’s picture

One more thing, the patch does not take into account a simple usecase: I want to show a block with user pictures (let's say random users) on a user page. This will cause the large images to be shown inside the block, whereas I'd expect the default ones. This is due to the line in the patched version

// If on user profile page
if (arg(0) == 'user' && is_numeric(arg(1))) {...

I was trying to figure out which test to add into this if clause, but in vain. phptemplate_user_picture has only one useful variable $account, which should have the distinguisher between the profile picture and all other pictures on the page, but I could not determine one.

Since my block is generated by views and it is of Node type I could get things working in my case with by changing the above code into:

// If on user profile page
if (arg(0) == 'user' && is_numeric(arg(1)) && !$account->nid) {...

Still it's just a partial solution. Any ideas?

marcingy’s picture

This issue is not about adding new features it is about updating the code as is to D6. Please raise a seperate issue for this new feature.

andypost’s picture

v1nce’s picture

Status: Reviewed & tested by the community » Postponed

I won't be releasing a 6 version of this module until ImageCache gets a stable 6.x version committed.

akahn’s picture

FileSize
28.66 KB

Just another verification that this patch works on Drupal 6.

One question, though, is Views integration. In a View, shouldn't the various ImageCache presets for a user's picture be available in the User: Picture field? Attached you'll see how I can set the label for the field, but not much else.

In there any way to control what image preset is used when presenting the user picture in a Views 2 view?

v1nce’s picture

Views integration is not available yet. See - http://drupal.org/node/217278.

drewish’s picture

just wanted to drop a note and say that imagecache on d6 is pretty stable at this point and any bug reports or feedback you've got as a result of updating this would be appreciated.

akahn’s picture

Hey V1nce, have you had a chance to try out this patch?

v1nce’s picture

Not yet. :(

olav’s picture

subscribe

unxposed’s picture

How can we get the default image profiles working on here?

Thanks

unxposed’s picture

I'm using #6 by the way... tried for hours and hours to get the patch working, but with no luck (and yes I read all the info on patching)!

akahn’s picture

unxposed: What version of this module were you applying the patch to? You have to patch the same version/release of the module as the patch was originally created for. It may help to post the errors you encountered.

unxposed’s picture

I followed these http://drupal.org/node/32875 instructions and I tired patching against 5.13, 5.14 and the version in post #6.

patch -p0 < imagecache_profiles_0.patch

but I got bash: patch: command not found

The version in #6 actually appears to be working straight up so I'm going with this. If I spend any more time trying to get the patch working (or have to install cygwin another time) I'm going to throw myself out the window (admittedly it is only a basement flat!).

The problem now is I have no defualt avatars, which I assume I need change the code in the .module file

It's currently:

    else if (variable_get('user_picture_default', '')) {
      $picture = variable_get('user_picture_default', '');
      if (isset($size)) {
        $picture = theme('imagecache', $size, $picture, $alt, $alt);
      }
      else {
        $picture = theme('image', file_create_url($picture), $alt, $alt, '', FALSE);
      }
    }
zilla’s picture

any chance this could be rolled up with patch and released as a 6.x dev version on the project page? seems like it's coming along well independent of views integration...

akahn’s picture

unxposed, it's not clear whether the patch is working or not for you. If you don't have patch installed, you aren't going to be able to apply the patch unless you do it by hand. But then again it sounds like the patch is working for you?

eikes’s picture

patch from #16 seems alright to me!

unxposed’s picture

No I couldn't get the patch working, so I'm just using the ported module from #6. Which is working, the only problem is now as I said above, no default avatars!

unxposed’s picture

Still can;t work out what to add in to get default avatars working again!

pfaocle’s picture

Version: 5.x-1.4 » 5.x-1.x-dev
Status: Postponed » Active

With Imagecache for 6.x now in beta, makes sense to reopen this issue.

momper’s picture

subscribe

unxposed’s picture

Okay I'm going to try and get the patch in #16 working in the hope that this will have support for default avatars, seeing as I've had no luck in getting the default avatars working in the ported version from #6. Could someone tell me which version I should apply this to 5.13 or the current version 5.14?

Thanks

unxposed’s picture

This is killing me, all I'm after is a version of imagecache profiles that works on 6, and supports my default avatars. : (

mariusooms’s picture

From comment #10:

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.

The provided patch (#16) does indeed support default avatars. Patch it against 5.x-1.4.

Regards,

Marius

unxposed’s picture

Thanks for the reply. Sounds like what I need! However I'm having absolutely NO luck with patching the files. Big ask, bu would anybody be kind enough to email me the patched version of 5.14 if they have it handy. Thanks!

japanitrat’s picture

i wonder when a patched version will find its way to the releases (at least a dev-release)

heather’s picture

Can anyone following this thread confirm if the port from 5 to 6 in #6 post is good-to-go?
http://drupal.org/node/225816#comment-927081

I'd like to know if anyone else is using this on a live site?

marcingy’s picture

Status: Active » Needs review

Yes we are using on this site

http://www.jackbe.com/enterprise-mashup

The patch in #16 is a result of that implementation

andypost’s picture

Is this module maintained?

@v1nce Please make a 6-dev

eikes’s picture

FileSize
3.29 KB

Yes, please do, you an use the attached Version, which I'm using... works fine

Bevan’s picture

Status: Needs review » Reviewed & tested by the community
FileSize
7.58 KB

The patch in #16 works for me, except for some minor changes to the *.info file. I rolled the attached patch from DRUPAL-5. The patch does'nt apply to HEAD. What's in HEAD? I think this is basically RTBC.

Junro’s picture

+1 need dev. version!

Thanks

babbage’s picture

I agree, time for a dev version for sure.

heather’s picture

ah, some progress- thanks guys,

so... does this mean that *for testing* i should use the compressed file in #61, in lieu of an official dev version? or does a patch need to be applied after?

Bevan’s picture

Heather, download 5-dev, and apply my patch in #62. See http://drupal.org/patch/apply for hlep on how to apply patches. If this is too much, you could download the tarball in #61 which is almost the same and will probably work fine.

mortenson’s picture

subscribing

jerdavis’s picture

Here is the code needed (along with a views 2 api call in the module file) to get views 2 support working. Create an includes folder within the imagecache_profiles module folder, then create and place these 2 files.

imagecache_profiles.views.inc
function imagecache_profiles_views_handlers() {
  return array(
    'info' => array(
      'path' => drupal_get_path('module', 'imagecache_profiles') .'/includes',
    ),
    'handlers' => array(
      'imagecache_profiles_handler_field_user_picture' => array(
        'parent' => 'views_handler_field_user_picture',
      ),
    ),
  );
}

function imagecache_profiles_views_data_alter(&$data) {
  $data['users']['picture']['field']['handler'] = 'imagecache_profiles_handler_field_user_picture';
}

imagecache_profiles_handler_field_user_picture.inc

class imagecache_profiles_handler_field_user_picture extends views_handler_field_user_picture {
  function options(&$options) {
    parent::options($options);
    $options['imagecache_preset'] = 'default';
  }
  
  function options_form(&$form, &$form_state) {
    parent::options_form($form, $form_state);
    $p = imagecache_field_formatter_info(); 
    foreach ($p as $key => $value) {
      $opt[$key] = str_replace('node', 'user', $value['label']);
    }
    $options = $this->options;
    $form['imagecache_preset'] = array(
      '#title' => t('Imagecache preset'),
      '#type'  => 'select',
      '#options' => $opt, 
      '#default_value' => $options['imagecache_preset'],
    ); 
  }

  function render($values) {
    // Fake an account object.
    $options = $this->options;
    $account = new stdClass();
    $account->uid = $values->{$this->aliases['uid']};
    $account->name = $values->{$this->aliases['name']};
    if (!$picture = $values->{$this->field_alias}) {
      $picture = variable_get('user_picture_default','');
    }
    $account->picture = str_replace(file_directory_path(). '/', '',$picture);
    
    return imagecache_profiles_imagecache_user_picture($options['imagecache_preset'], $account->picture, $account->uid, $account->name);
  }
}

Then add this in imagecache_profiles.module

function imagecache_profiles_views_api() {
  return array(
    'api' => 2,
    'path' => drupal_get_path('module', 'imagecache_profiles') .'/includes',
  );
}
Bevan’s picture

FileSize
7.53 KB

Oops. I introduced an unnecessary dependency on profile module in my previous roll of this patch. This fixes that issue.

Bevan’s picture

jerdavis, what does this do that imagecache_profiles deosn't already do?

jerdavis’s picture

Bevan,

This provides the imagecache formatters for the user picture within views as mentioned in #37 and http://drupal.org/node/217278. I'd originally posted that I had written the code in issue 217278 but seeing as how there is not a d6 branch in cvs yet I decided to post the code here in case people wanted to incorporate it and test it further in the interim.

While imagecache profiles covers many use cases on it's own, it is still somewhat limiting. In cases where you want to select more varied preset sizes for different applications (usually the result of a view) this little bit of extra code covers those bases.

That said, it is pretty stand alone code, so if there's a feeling that this should be a separate module that could work alongside or instead of imagecache profiles then I'd be happy to branch it off.

Jer Davis

Bevan’s picture

Jer,

I see. I haven't had a use case to need more display options with views yet, but it probably makes sense to be part of this module. I suggest you attach the files in a separate issue node though, so that it can be reviewed and committed separately.

This module also looks like it needs a new maintainer if anyone is interested...

v1nce’s picture

I'm gonna get a 6.x branch out soon.

v1nce’s picture

Version: 5.x-1.x-dev » 6.x-1.0
Assigned: Unassigned » v1nce
Status: Reviewed & tested by the community » Fixed

I've released a 6.x branch. Anybody that may be using pathces or versions from this thread would be advised to update their module to the official release.

None of the patches or versions were utilized from this thread.

japanitrat’s picture

thanks for the branch v1nce!

though the views 2 support wouldve been nice. maybe next release

japanitrat’s picture

*rewind* hmm, doesnt seem to work that branch.

andypost’s picture

Thanks a lot for commit!
Here views 2 integration issue #349331: Views 2 Support in 6.x + optimizations

Bevan’s picture

If you are migrating from this patch to DRUPAL-6--1 (aka 6.x-1.0) then you'll need to re-select settings on admin/user/settings, since this patch stores IC id numbers, while 6.x-1.0 stores IC machine names. This results in markup like <img src="http://example.com/files/imagecache/3/user-pictures/picture-6.jpg" /> instead of <img src="http://example.com/files/imagecache/thumbnail/user-pictures/picture-6.jpg" /> (simplified for demonstration).

Note 3 instead of thumbnail in the URL, where 3 is IC's id for the thumbnail IC preset.

After re-selecting the IC presets on admin/user/settings this problem is resolved and the correct image source is used.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for two weeks with no activity.

asiby’s picture

Title: Port of ImageCache Profiles to D6 » I don't mean to be a show stopper but ...

... isn't it way simpler to just to the following? ...

print theme('imagecache', ‘my_preset’, $my_variable, $alt, $title, $attributes);

asiby’s picture

Title: I don't mean to be a show stopper but ... » Port of ImageCache Profiles to D6

Sorry. This form is not user friendly. I had accidentally changed the title of the issue. I am setting it back.

asiby’s picture

I don't mean to be a show stopper but isn't it way simpler to just to the following? ...

print theme('imagecache', ‘my_preset’, $my_variable, $alt, $title, $attributes);
Bevan’s picture

This issue is closed. You should probably open a new issue if you want your question to get noticed. Make sure you are clear about what that code snippet would replace.