Hi,

Your module works fine, and I do plan to use it for other files than just images. It is possible, as with the php templates I can display the fields the way I want to.

But to use it for other files than just plain images, some features are missing, and perhaps we can imagine adding them. For example, of course if I attach a pdf there is no image preview available. But the file name is not displayed either. So perhaps it could be good to display the file name above or below the image preview.

Perhaps we could imagine as well using the GD library to display image preview. This way it can work with pdf files too, or any other file supported by GD.

So those two features are features that can be useful for images, and that will allow using this for plain file attachment.

Thanks

CommentFileSizeAuthor
#6 imceimage.patch9.39 KBpaulmckibben

Comments

AxelBernhardt’s picture

I helped myself with adding some code into my template.php

function phptemplate_imceimage_formatter_default($element) {
	$item = $element['#item'];
	$field = $element['#field_name'];
	$delta = $element['#delta'];
	$id = "imceimage-". $field ."-". $delta;

	return my_theme_imceimage_image($item['imceimage_path'],$item['imceimage_width'],$item['imceimage_height'],$item['imceimage_alt'],$id);
}

function my_theme_imceimage_image($s, $w='', $h='', $a='', $id='') {
	$add = "";
	if(stristr($s, '.pdf')){
		$sArr = split('/', $s);
		$pdfName =$sArr[sizeof($sArr) -1]; 
		$add = '<a href="'. $s . '" >' . $pdfName . '</a>';
		$s = "/xyz/pdf-icon.jpg";
		
	}
	$s = 'src="'. $s .'" ';
	$a = 'alt="'. $a .'" ';
	$id = !empty($id)? 'id="'. $id .'" ':'';
	$w = !empty($w)? 'width="'. $w .'" ':'';
	$h = !empty($h)? 'height="'. $h .'" ':'';
	return '<img '. $s . $a . $w . $h . $id .'/>' . $add;
}

function phptemplate_imceimage($element) {
	if(stristr($element['#default_value']['imceimage_path'], '.pdf')){
//		$pdfIcon = "/xyz/pdf-icon.jpg";
//		$element['#children'] = str_replace($element['#default_value']['imceimage_path'], $pdfIcon, $element['#children']);
// this attempt caused problems ...
	}
	$add = "<br>" . $element['#default_value']['imceimage_path'] ;
	return $element['#children'] .$add ;
}
Julien PHAM’s picture

Your code is to display the files into the node? Or is it for administration purpose?
I mean, what I need is not a way to display pdf in my theme, with imce image, I already did this another way. What I need is a way to modify the way imce cck image works when we are in node creation or editing mode.

What I would like to see in node creation is that if imce cck image is unable to create a preview of the image for some reason (for instance if this is not an image) then it will display the file name instead... in the edit form. So I know in the list of files on what files I'm working on.

Thanks

paulmckibben’s picture

I have a client that needs this functionality as well. I am working on a patch and will post it here in the next few days.

gwynnebaer’s picture

+1

This, in my view, would be a much more seamless upload solution than some of the others I have seen. I look forward to the patch, @pmckibben.

paulmckibben’s picture

Patch coming soon. I apologize for the delay--crazy work commitments!

paulmckibben’s picture

StatusFileSize
new9.39 KB

This is a patch for imceimage 6.x-1.0-beta2. It adds a new widget for "generic file" that allows you to attach any file. The widget for attaching an image is unchanged, other than some minor UI improvements.

Sorry this took so long.

visualnotion’s picture

Is it likely to have this rolled into the dev release? I get a lot of people requesting this as well and it certainly seems handy to have this in the module by default.

I'm sure there are some other issues I'm not thinking of, but I'm sleep deprived, at the moment.

elijah lynn’s picture

This is great!

paulmckibben’s picture

Version: 6.x-1.x-dev » 6.x-1.0-beta2
Status: Active » Needs review

@visualnotion: I'm not the maintainer of this module, but I have changed the status of this issue to "needs review" in hopes that maybe it will get some attention from the maintainer.

elijah lynn’s picture

pmckibben: I applied this patch and when I save the node it has a place for the file but no link or name etc. Any ideas?

Also any idea on how to make this work with the forum comments?

paulmckibben’s picture

I forgot that I never created a formatter to generate default output, so I apologize. The way I'm using this for my client, it's highly customized and uses a special node template. I'll see if I can find some time in the next week to add a default formatter.

For now, you can either create a custom theme template for your node, e.g. node-[mynodetype].tpl.php, or use the Content Template (http://drupal.org/project/contemplate) module to customize the node's output.

For your IMCE field, pretending your field name is "imce_file", you use:

$node->field_imce_file[0]['imceimage_path'] 

The above gives you the file path.

I don't use forums, so I'm afraid I can't help you with forum comments. Can you even use CCK with comments? I don't think you can, but I may be wrong. However, if you're using a rich text editor, some rich text editors provide a link tool that allow you to use IMCE to link to a file. I am using the WYSIWYG API (http://drupal.org/project/wysiwyg) with fckeditor, and if you have the WYSIWYG IMCE bridge module (http://drupal.org/project/imce_wysiwyg), the link tool will allow you to use IMCE to browse/upload and link to a file. Would that serve your purpose?

mikeque’s picture

Nice work on that patch. It definitely should be integrated into the plugin. I hope.

panis’s picture

Assigned: Unassigned » panis
Status: Needs review » Closed (won't fix)

sorry - imceimage is just meant for images - hence the name. I agree the same framework can be extended to other file types and thank you for the patch. I will consider in the longer term - moving to a "imce cck file" module - to handle any type of file - but not for now.