a strange error have occurred:

if im using the admin module's theme slate
the markup im getting inside an textarea is by clicking the insert button is

<img src="" alt="" title="" class="imagecache-large" />

but if i change my admin theme to another theme if get
<img src="http://foo/sites/default/files/imagecache/large/images/foo.jpg" alt="" title="" class="imagecache-large" />

CommentFileSizeAuthor
#35 insert-hook_theme.patch1007 byteszroger
#16 admin_insert.zip1.88 KBjrefano

Comments

quicksketch’s picture

Slate is probably changing the HTML in a way that makes it so that Insert can no longer operate, since it is dependent on HTML classes to operate properly. I'll see what it's doing, but this very well could be a problem with Slate (which does all sorts of really drastic changes).

PieWie’s picture

Title: insert & admin module (slate) » insert bug report

I hew the same

by clicking the insert button i become

<img src="" width="" height="" alt="" title="" />

i use

Insert 6.x-1.0-beta2
ImageField 6.x-3.2
Image Resize Filter 6.x-1.5
FileField Paths 6.x-1.3
FileField 6.x-3.2
Content Construction Kit (CCK) 6.x-2.6

andrew_kabai’s picture

i can also confirm the bug.

if i upload something (cck filefield) then the insert options is available, but it makes empty links or img html tags without src.

i use the following modules:
cck 6.x-2.6
filefield 6.x-3.2
imagefield 6.x-3.2
filefield paths 6.x-1.3
insert 6.x-1.0-beta2

jsm174’s picture

I can also confirm this.

I have two insert styles, an imagecache "resize-200-200" and "fancybox-resize-200-200" (dynamic from fancybox d6 module).

If I am creating a new node, and upload a new image, I can insert into CKEditor with no problem, either style.

If I come back to edit the node, and try to insert the existing image again using the resize-200-200 style, it comes back empty with

   <img alt="demo" class="imagecache-resize-200-200" src="" title="">

If I try to use the fancybox-resize-200-200, it comes back correctly with

   <a class="fancy_box" href="http://www.mysite.com/sites/default/files/chevron-normal.png" rel="loop--122" title="chevron"><img alt="" src="http://www.mysite.com/sites/default/files/imagecache/resize-200-200/chevron-normal.png"></a>

So it seems as if there may be an issue with a plain imagecache insert while editing an existing node.

-- Jason

jsm174’s picture

I have another update.

I just tried another edit. If I click the imagefield I want to reuse, and then click "Reference existing" (filefield sources) and then Select (to use the existing FID), I can continue inserting both styles with no problems.

PieWie’s picture

Unfortunately, despite the addition of the module filefield sources
with me on the path src is empty

and i do not use any editor viswig

johngriffin’s picture

I am having the same problem. I'd be happy to help debug if you can give me some hints on where to look, I don't have a great deal of time to investigate though right now.

I have just updated from filefield_insert to insert, I have the latest stable versions of cck (6.x-2.6), filefield (6.x-3.2) and imagefield (6.x-3.2)

It appears that when I try to use "Insert" on a filefield which already contained a file before the upgrade, the following is inserted into the body:

<img src="" width="" height="" alt="" title="" />

If I upload a new file and then try to use Insert it works as expected.

trevortwining’s picture

Title: insert bug report » Admin.module conflect with insert() function (

It looks like when slate is enabled maxwidth or the other values don't get set in the insert() function on line 34 of insert.js. I'm still grokking the code at this point but here's what an output of all the properties in settings looks like


undefined maxWidth: 
undefined wrapper: .filefield-element 
undefined fields 
  undefined alt: input[name$="[alt]"] 
  undefined title: input[name$="[title]", textarea[name$="[title]"] 
  undefined description: input[name$="[description]"], 
textarea[name$="[description]"] 

trevortwining’s picture

Title: Admin.module conflect with insert() function ( » Admin.module conflect with insert() function (Slate theme won't insert image)

adjusting title due to premature submit

mortendk’s picture

Not a pretty solution ... but a solution ;)

So heres the problem:
The slate theme (or is it admin that does that ?) overwrites the preprocess functions that **insert module** uses for adding the options in the hidden fields for each of the files that are uploaded (apperently this is not the case when a file is just uploaded)

So to overwrite that just add the preprocess functions into admin template.php file
admin/template.tpl

/*-----------------------
 Insert modules preprocess functions
 original preprocess are from insert/include/insert.inc & insert/include/imagecache.inc
/*-----------------------*/
function slate_preprocess_insert_image(&$vars) {
  $vars['url'] = file_create_url($vars['item']['filepath']);
  $vars['class'] = !empty($vars['widget']['insert_class']) ? $vars['widget']['insert_class'] : '';
  $image_info = @image_get_info($vars['item']['filepath']);
  $vars['width'] = isset($image_info['width']) ? $image_info['width'] : '';
  $vars['height'] = isset($image_info['height']) ? $image_info['height'] : '';
}

function slate_preprocess_insert_link(&$vars) {
  $vars['url'] = file_create_url($vars['item']['filepath']);
  $vars['class'] = !empty($vars['widget']['insert_class']) ? $vars['widget']['insert_class'] : '';
  $vars['name'] = $vars['item']['filename'];
}

function slate_preprocess_imagecache_insert_image(&$vars) {
  $vars['filepath'] = $vars['item']['filepath'];
  $vars['url'] = imagecache_create_url($vars['preset_name'], $vars['item']['filepath']);
  $vars['class'] = !empty($vars['widget']['insert_class']) ? $vars['widget']['insert_class'] : '';
}

This is for the 1.0 branch of admin module havent look into it yet in the 2.0

also reported here http://drupal.org/node/649742

malclocke’s picture

Very similar problem to johngriffin here. After upgrade from filefield_insert I get <img src="" width="" height="" alt="" title="" /> tags created by 'Insert'. Difference in my case is that no inserts work, either old pre upgrade images or newly uploaded ones.

Problem seems to be that I am never getting into template_preprocess_insert_image() at includes/insert.inc:44, some debug print statements in there never get called. If I copy the preprocess code to mytheme_preprocess_insert_image() everything works.

Bizarrely, 'grep -rl preprocess_insert_image .' from my site root doesn't find any other occurrences of that preprocess function. What other candidates could be stopping the preprocess from running?

Site is using cck 6.x-2.5, filefield 6.x-3.2, imagefield 6.x-3.1 and a zen 6.x-1.0 sub theme.

giorgosk’s picture

Title: Admin.module conflect with insert() function (Slate theme won't insert image) » Some themes won't let image insert

The problem occurs with more themes than just slate
I am using a subtheme of adaptivetheme 2.x

solution in #10 worked for me for original image not for imagecache presets though

NOTE: that if I use phptemplate_preprocess_insert_image instead of THEMENAME_preprocess_insert_image and similarly the rest the insert does not work

quicksketch’s picture

Category: bug » support

Now that I see what the problem is, I don't think there's much that Insert module can do. The fact that Slate (Admin module 1.x) and the Adaptive Theme abuse the theme system in completely unholy ways is a problem with those themes, not a problem with Insert. I don't think there's anything that can be done by Insert other than not using .tpl.php files, which would be a step backward. The 2.x version of Admin module should be much cleaner because it doesn't jam an admin theme into your site through a series of ridiculous hacks. I'm not sure what to say about Adaptive Theme since I have never used it.

mason@thecodingdesigner.com’s picture

subscribe

mark.’s picture

.

jrefano’s picture

StatusFileSize
new1.88 KB

I took morten's code and made a quick module for anyone who is using Admin/Slate and Insert, so you can just drop it in and enable it. Note that this fix has only been tested on Admin 1.x.

perandre’s picture

Hm, couldn't make it work with admin 1 beta 3.

Edit: Nevermind; didn't work with Admin module disabled, either.

grantkruger’s picture

What does not entirely make sense is how it was working fine and then stopped working somewhere along the way. In my case I'm using Admin with Slate and Tendu (a Zen variant). Admin module's recommended version is what I'm using and it was last updated 2009-Jul-30, whereas Insert has been updated many times since then. Further, in my case it seems to work sometimes, but not others. Sometimes it inserts a blank image and other times it points to a thumbnail that was never created. It's all a little beyond me.

So do we now have an either or on Admin and Insert? Recommendations?

EDIT: Okay, my problem seems to have gone away. I can't be specific, because I changed a lot of settings, but I can say that I was having some ImageCache and Lightbox2 issues. Which means I appear to have Insert working with Admin. Further, as an oddity, my Mac allows an ampersand (&) in file names, but most image modules behaved very strangely when an & is in a file name. I suspect there is a security hole in the mix. All of this is just FYI.

jedihe’s picture

I've found this problem too, using Admin module 1.0 beta 3. In my case, insertion worked when creating the node, but not when editing it (the wysiwyg received an img tag only with the class attribute, no src).

The good news is I just upgraded to Admin 2.0Beta1 + Rubik Theme and now insert works nicely.

jedihe

btc97’s picture

I had this same issue: none of my image urls were inserted after switching from Filefield Insert to Insert. My custom theme doesn't override any preprocess insert function, as far as I can see, so I'm still not sure what caused this... Another module?

giorgosk’s picture

use #10 function in your template.php with with name such as phptemplate_preprocess_insert_ or THEMENAME_preprocess_insert_

quicksketch’s picture

Version: 6.x-1.0-beta2 » 6.x-1.0-beta3
Status: Active » Fixed

I think this problem may have been fixed as part of #739280: Unregistered preprocess functions. I'm making a beta4 release today, please reopen if this problem still exists in that version.

kevinwalsh’s picture

Version: 6.x-1.0-beta3 » 6.x-1.0-beta4
Status: Fixed » Needs work

I updated to beta4 but the issue persists, using a theme based on Acquia Marina. Solved with Morten's fix at #10

quicksketch’s picture

Thanks kevinwalsh for the update. So, still not much to be done by us it seems. :-(

perandre’s picture

On a related note: I've had problems inserting files in general into the wysiwyg on some occations. After changing DEFAULT INSERT STYLE: Automatic -> Link to file, it started working.

JJG’s picture

I think i have the same problem the insert option doesnt appear in the "manage fields" that really sucks since im using lullabot videos and their theme to follow what they do in the videos

entrigan’s picture

I had this problem until downgrading to beta4 from dev

apolitsin’s picture

this problem too

apolitsin’s picture

this code works:
/sites/all/modules/insert/includes/imagecache.inc
line 23-...

/**
 * Implementation of hook_insert_content().
 */
function imagecache_insert_content($item, $style, $widget) {
  $preset_name = preg_replace('/^imagecache_/', '', $style['name']);
  $filepath = imagecache_create_path($preset_name, $item['filepath']);
  $url = insert_create_url($filepath);
  return theme('imagecache_insert_image', $item, $widget, $preset_name, $url);
}

/sites/all/modules/insert/insert.module
line 71
'arguments' => array('item' => NULL, 'widget' => NULL, 'preset_name' => NULL, 'url' => NULL),
желаю всем счастья, любви и удачи! =)

PieWie’s picture

for me it does not work :(

i still do not have the path to file
<img src="" alt="" title="" class="imagecache-manual" />

apolitsin’s picture

have you flush cache?

PieWie’s picture

yes

I also have a problem now with the right to the directory "files"
although the law has 777 drupal does not see those rights
may be something else is wrong
I do not know where to look for reasons

Melissamcewen’s picture

I'm having this problem as well. N-thing "What does not entirely make sense is how it was working fine and then stopped working somewhere along the way."

echoz’s picture

I want to add to this issue with what I hope is a clue, although may be for the other involved module, where I will post as well. We have insert working flawlessly, then after installing SimpleMenu 6.x-1.7 http://drupal.org/project/simplemenu, we get an empty image tag
<img class="imagecache-large" alt="">

Based on a SimpleMenu js bug report #837956: Simplemenu 1.5 to 1.8 breaks javascript sitewide (if files is not created, old behavior does not take over automatically.) downgrading to SimpleMenu 1.4 allows insert to function normally again. Edit: The dev version from 7/1 of simplemenu resolves this issue.

I tested with today's updates of filefield 6.x-3.7 + imagefield 6.x-3.7 with no change.

zroger’s picture

Version: 6.x-1.0-beta4 » 6.x-1.x-dev
Category: support » bug
Status: Needs work » Needs review
StatusFileSize
new1007 bytes

This is actually a bug in the hook_theme implementation. I figured it out by inspecting the theme registry using the devel module. Here's what i found. http://skitch.com/zroger/dqhiw/theme-registry-optionsprofits

The patch fixes the hook_theme implementation.

quicksketch’s picture

Status: Needs review » Reviewed & tested by the community

Wow, yikes! Thanks Roger! I'll put this in and make a new release.

mstrelan’s picture

Priority: Normal » Critical

When is this new release coming? This is really critical for insert to work correctly.

divbox’s picture

I just came across something, which, in the end was simple to resolve, but took a while to figure out.

I was having a similar problem, where I would click insert, but nothing would go to the text area.

I have set up my own template on a node add form, so I am not using the standard node/add form. Perhaps it was how I output the form (drupal_render), but I ended up w/out a wrapping

<div class="node-form">

around my form. Without this, the jquery function did not fire

$('.node-form textarea:not([name$="[data][title]"])', context).focus(insertSetActive).blur(insertRemoveActive);

Looking at insert.js, I think this may be due to me using ckeditor module, instead of wyswyig api module and ckeditor, but I'm not 100% sure.

Hopefully this helps someone

quicksketch’s picture

Status: Reviewed & tested by the community » Fixed

I've committed the patch from #35. Thanks zroger!

Status: Fixed » Closed (fixed)

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