| 1 |
<?php
|
| 2 |
/**
|
| 3 |
* Implementation of hook_ulink_image()
|
| 4 |
*/
|
| 5 |
function ulink_ulink_image($link, $object=NULL){
|
| 6 |
switch (variable_get('ulink_image_settings', '0')) {
|
| 7 |
case '0':
|
| 8 |
// having alt and theme will have an effect of having double alt, title tags (eg: alt given directly and alt from atttributes but for compatibility it is left as repeating tags don't do any harm
|
| 9 |
return theme('image', $link['path'], $link['attributes']['alt'], $link['attributes']['title'], $link['attributes'], FALSE);
|
| 10 |
case '1':
|
| 11 |
$text = $link['text'] ? $link['text'] : $link['path'];
|
| 12 |
return l($text, $link['path'], $link['attributes'], NULL, NULL, FALSE, TRUE);
|
| 13 |
case '2':
|
| 14 |
$image = theme('image', $link['path'], $link['attributes']['alt'], $link['attributes']['title'], $link['attributes'], FALSE);
|
| 15 |
return l($image, file_create_url($link['path']), $link['attributes'], NULL, NULL, FALSE, TRUE);
|
| 16 |
}
|
| 17 |
}
|
| 18 |
/**
|
| 19 |
* Implementation of hook_ulink_image_settings()
|
| 20 |
*/
|
| 21 |
function ulink_ulink_image_settings(){
|
| 22 |
$options = array('0' => t('Only image'), '1' =>t('Only link'), '2' => t('Image and link'));
|
| 23 |
$form['ulink_image_settings'] = array(
|
| 24 |
'#title' => t('Redering option'),
|
| 25 |
'#type' => 'radios',
|
| 26 |
'#options' => $options,
|
| 27 |
'#default_value' => variable_get('ulink_image_settings', '0'),
|
| 28 |
'#description' => (module_exists('imagecache')&&module_exists('ulink_imagecache') ? t('Please use <a href="!settings">ulink_imagecache</a> implementation for images. For specific rendering, please remove the extension from the list and add it in the others/files category with implementation.', array('!settings' => url('admin/settings/ulink/image'))) : t('<strong>Note:</strong> If <a href="!imagecache">Imagecache</a> module and ulink_imagecache are installed, uLink provides support for image scaling. For specific rendering, please remove the extension from the list and add it in the others/files category with implementation.', array('!imagecache' => url('http://drupal.org/project/imagecache')))),
|
| 29 |
);
|
| 30 |
return $form;
|
| 31 |
}
|
| 32 |
/**
|
| 33 |
* Implementation of hook_ulink_image_info().
|
| 34 |
*/
|
| 35 |
function ulink_ulink_image_info() {
|
| 36 |
return t(' If imagecache is available, please use ulink_imagecache implementation - it is used for images from "files/". Otherwise HTML image tag is rendered. User can override this by specifying force_link=true : attach the imagefile instead displaying it.');
|
| 37 |
}
|