Override theme_node_preview I'm using a custom theme but Seven as administration theme.

How can I override the theme function 'theme_node_preview'?

Notice that theme_node_preview is called in the node form, and it's shown in an overlay. So it's part of the admnistration theme.


I tried to used the generic phptemplate_ prefix but this way of overriding theme functions was removed for Drupal 7.
I tried seven_node_preview from a module and also from the template.tpl.php of my custom theme, but didn't work.
I don't want to create a subtheme of Seven only for this.
I know you explicitly stated that you don't want to create a subtheme of Seven, however short of hacking the core Seven theme or messing with the theme registry (which I explain below against my better judgement) this is the simplest way to accomplish what you are trying to do.  The amount of overhead to do this is incredibly small and requires only three files.  Simply create a folder named something like "mytheme" and add an empty "mytheme.css" file in addition to a "mytheme.info" file with the following code:

name = My Theme
description = Custom subtheme of Seven.
core = 7.x
base theme = seven
stylesheets[all][] = mytheme.css


Then add a template.php file and override the theme hook similar to below:

function mytheme_node_preview($variables) {
  // Do custom stuff here.
}


All done. This is the "Drupal way" of doing theme hook overrides.

Again, it is against my better judgement to post the code below. If you absolutely have your mind set on not creating a subtheme, you can implement hook_theme_registry_alter().  Did I mention that this solution is hacky and the hook is pure evil? :-) In a custom module named "mymodule", do the following:

function mymodule_theme_registry_alter(&amp;$registry) {
  $path = drupal_get_path('module', 'mymodule');
  $registry['node_preview']['file'] = 'mymodule.module';
  $registry['node_preview']['theme path'] = $path;
  $registry['node_preview']['function'] = 'mymodule_node_preview';
  $registry['node_preview']['includes'] = array(
    $path . '/mymodule.module'
  );
}

function mymodule_node_preview($variables) {
  // Do whatever you need to do here.
}


Use the snippet above at your own risk.