tweak_handler_field_user_picture_preset.inc 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. <?php
  2. /**
  3. * Field handler to provide simple renderer that allows using a themed user link
  4. */
  5. class tweak_handler_field_user_picture_preset extends views_handler_field_user_picture {
  6. function option_definition() {
  7. $options = parent::option_definition();
  8. $options['preset'] = array(
  9. 'default' => $this->definition['preset'],
  10. 'translatable' => FALSE,
  11. );
  12. return $options;
  13. }
  14. /**
  15. * Choose a preset
  16. */
  17. function options_form(&$form, &$form_state) {
  18. parent::options_form($form, $form_state);
  19. $options = array('0' => t('None'));
  20. foreach (imagecache_presets() as $pid => $preset) {
  21. $options[$pid] = $preset['presetname'];
  22. }
  23. $form['preset'] = array(
  24. '#type' => 'select',
  25. '#title' => t('Imagecache preset'),
  26. '#options' => $options,
  27. '#default_value' => isset($this->options['preset']) ? $this->options['preset'] : '0',
  28. );
  29. }
  30. function admin_summary() {
  31. $pid = $this->options['preset'];
  32. if ($pid) {
  33. $preset = imagecache_preset($pid);
  34. $ret = $preset['presetname'];
  35. }
  36. else {
  37. $ret = t('Raw');
  38. }
  39. return $ret;
  40. }
  41. function render($values) {
  42. $pid = $this->options['preset'];
  43. if ($pid) {
  44. $preset = imagecache_preset($pid);
  45. return theme_imagecache($preset['presetname'], $this->get_value($values));
  46. }
  47. else {
  48. return parent::render($values);
  49. }
  50. }
  51. }