Hi,
thank you for create this amazing module,
I know you added support to Lightbox that's great, but I think there are many newest and smallest modal scripts in jquery, like fancybox, a jquery native script.

There is a Fancybox drupal module

Comments

eugenmayer’s picture

its a one line integration. Please provide a patch and participate :)

Anonymous’s picture

I wish I could! :) Please, give me a clue and tell me where that 'one line' goes and I'll try. I suffer code blindness and I have an illogic mind too. What can I do? ;)

troyer’s picture

Honestly the Lightbox submodule is pretty small, so you can learn a lot from digging through the code. It's pretty hard for one programmer alone to maintain support for each and every imagebox implementation. At least try to understand and take a look at the code.

Anonymous’s picture

@drupidoo I understand your point of view, my skills let me modify some themes/templates functions or create new themes but I am not a programmer and I can not trying to act as one. I do respect Eugen's time and effort, like I really do with any other open source developer. This is not an order it is just a request, you could take into account or just ignore it.

regards,

Anonymous’s picture

Status: Active » Needs review

Here it's my little contribution: Fancybox integration.

Please, review the code. I can't get to print the rel attribute (to grouping images on the same page), it is necessary to add a jquery selector:
$("a.fancybox").fancybox();

Regards,

I don't know how to create a patch, so I will paste the code here:

wysiwyg_imageupload_fancybox.info

; $Id$
name = WYSIWYG Image upload - Fancybox integration
description = Image upload dialog for the most WYSIWYG Editors
dependencies[] = wysiwyg_imageupload
dependencies[] = fancybox
package = Drupal Wiki
core = "6.x"
project = "wysiwyg_imageupload_fancybox"

wysiwyg_imageupload_fancybox.install

// $Id$

function wysiwyg_imageupload_fancybox_install() {
  db_query("UPDATE {system} SET weight = 10 WHERE name = 'wysiwyg_imageupload_fancybox'");
  wysiwyg_imageupload_fancybox_add_field();
}

/**
 * Implementation of hook_schema().
 */
function wysiwyg_imageupload_fancybox_add_field() {
  $ret = array();

  $fancybox = array(
    'type' => 'int',
    'not null' => TRUE,
    'default' => -1,
    'description' => 'Use fancybox integration or not',
  );
  db_add_field($ret, 'wysiwyg_imageupload_entity', 'fancybox', $fancybox);
  return $ret;
}

function wysiwyg_imageupload_fancybox_schema_alter(&$schema) {
  // Add field to existing schema.
  $schema['wysiwyg_imageupload_entity']['fields']['fancybox'] = array(
    'type' => int,
    'not null' => TRUE,
    'default' => -1,
    'description' => 'Use fancybox integration or not',
  );
}
/**
 * Implementation of hook_uninstall().
 */
function wysiwyg_imageupload_fancybox_uninstall() {
  // Remove tables.
  db_drop_field($ret, 'wysiwyg_imageupload_entity', 'fancybox');
  // Remove variables.
  db_query("DELETE FROM {variable} WHERE name LIKE 'wysiwyg_imageupload_fancybox_%%'");
}

wysiwyg_imageupload_fancybox.module

// $Id$
// Copyright (c) 2010 KontextWork GbR
// Author: Eugen Mayer

/**
 * Thats where we actually alter the form and add our extra meta data
 * The loaded $img_obj hold your data dui to the hook_wysiwyg_imageupload_entity_load_alter
 * We use the value to set our default value
 */
function wysiwyg_imageupload_fancybox_form_alter(&$form, &$state, $form_id) {
  if ( $form_id == 'wysiwyg_imageupload_edit_form') {
    // You always find the IID here
    $iid = $form['image_upload_details']['iid']['#value'];
    $img_obj = _wysiwyg_imageupload_load_inline_entity($iid);

    $default = variable_get('wysiwyg_imageupload_fancybox_default', 1);
    // only use the defaul if nothing set yet
    if ($img_obj->fancybox > -1) {
      $default = $img_obj->fancybox;
    }

    $form['image_upload_details']['extras']['fancybox'] = array(
      '#title' => t('Popup'),
      '#description' => t('Preview original-size picture on click'),
      '#type' => 'checkbox',
      '#default_value' => $default,
    );
  }
  elseif ($form_id == 'wysiwyg_imageupload_admin_settings') {
    wysiwyg_imageupload_fancybox_admin_settings($form);
  }
}

function wysiwyg_imageupload_fancybox_theme() {
  return wysiwyg_imageupload_theme();
}

/**
 * Implementation of hook_wysiwyg_imageupload_entity_save().
 */
function wysiwyg_imageupload_fancybox_wysiwyg_imageupload_entity_save($post, $iid) {
  // $post has the $form_state['values'], so we find our form element there (the value)
  $update = array(
    'iid',
  );

  $record = array(
    'fancybox' => $post['fancybox'],
    'iid' => $post['iid'],
  );
  drupal_write_record('wysiwyg_imageupload_entity', $record, $update);
}

/************* Everything below is optional ********************************************** */

/**
 * Implementation of hook_wysiwyg_imageupload_entity_load_alter().
 * This is an example for how to load values if you stored the meta data in a different table
 * them wysiwyg_imageupload_entity
 * YOU DONT need to implement this if you actually store your meta data IN the wysiwyg_imageupload_entity
 * table
 */
/*
function wysiwyg_imageupload_fancybox_wysiwyg_imageupload_entity_load_alter($entity, $iid) {
  $result = db_fetch_object(db_query('SELECT fancybox FROM {some_relation_table} WHERE iid=%d',$iid);
  $entity->fancybox = $result->fancybox;
}*/

/**
 * This is optional. We alter the wysiwyg_imageupload admin settings
 * to provide some settings for our module. If you dont need those
 * you dont need to implement thise
 */
function wysiwyg_imageupload_fancybox_admin_settings(&$form) {
  $presets = imagecache_presets();
  $styles = array();
  foreach ($presets as $preset) {
    // We can use the presetid here (http://drupal.org/node/694188).
    $styles[$preset['presetname']] = t("!preset", array('!preset' => $preset['presetname']));
  }

  $form['wysiwyg_imageupload_fancybox_settings'] = array(
    '#type' => 'fieldset',
    '#title' => t('fancybox settings'),
    '#description' => t('Only the selected presets are allowed to be chosen in the dialog'),
    '#collapsed' => TRUE,
    '#collapsible' => TRUE,
    '#weight' => 0,
  );

  $form['wysiwyg_imageupload_fancybox_settings']['wysiwyg_imageupload_fancybox_preset'] = array(
    '#type' => 'select',
    '#title' => t('What preset to use for the popup?'),
    '#description' => t('This preset will be used to show the image in the fancybox'),
    '#default_value' => variable_get('wysiwyg_imageupload_fancybox_preset', 'wysiwyg_imageupload_fancybox_preset'),
    '#options' => $styles
  );
  $form['wysiwyg_imageupload_fancybox_settings']['wysiwyg_imageupload_fancybox_default'] = array(
    '#type' => 'checkbox',
    '#title' => t('Default value'),
    '#description' => t('If checked, fancybox integration will be checked in the image detail form by default'),
    '#default_value' => variable_get('wysiwyg_imageupload_fancybox_default', 1),
  );
}

function wysiwyg_imageupload_fancybox_wysiwyg_imageupload_rendered_image_alter(&$img, $img_obj) {
  $default = variable_get('wysiwyg_imageupload_fancybox_default', 1);
  // only use the defaul if nothing set yet
  if ($img_obj->fancybox > -1) {
    $default = $img_obj->fancybox;
  }

  if ($default != 0) {
    $transformed_path = imagecache_create_url(variable_get('wysiwyg_imageupload_fancybox_preset', 'wysiwyg_imageupload_fancybox_preset'), $img_obj->filepath);
    $link_attributes = array(
      'rel' => 'fancyboxgroup',
      'class' => 'fancybox',
      'title' => $img_obj->title
    );
    $img = l($img, $transformed_path, array('html' => TRUE, 'attributes' => $link_attributes));
  }
}

/**
 *  Those presets are needed for the fancybox
 */
function wysiwyg_imageupload_fancybox_imagecache_default_presets() {
  $presets = array();
  $presets['wysiwyg_imageupload_fancybox_preset'] = array(
    'presetname' => 'wysiwyg_imageupload_fancybox_preset',
    'actions' => array(
      0 => array(
        'weight' => '0',
        'module' => 'imagecache',
        'action' => 'imagecache_scale',
        'data' => array(
          'height' => '768',
          'width' => '1280',
        ),
      ),
    )
  );

  return $presets;
}
eugenmayer’s picture

Thank you! I will integrate this in the next release

eugenmayer’s picture

Status: Needs review » Patch (to be ported)
eugenmayer’s picture

Version: 6.x-2.0-rc7 » 6.x-2.4
Status: Patch (to be ported) » Needs review

As 2.5 should be a maintainance release, i will take this one in for 2.6. Cann someone confirm thats working? (e.g. the code of the .info file is flaky)

eugenmayer’s picture

Status: Needs review » Fixed

included in 2.5

Thanks for the contribution :)

Anonymous’s picture

Your welcome ;)

eugenmayer’s picture

Status: Fixed » Closed (fixed)