I added this code to the image_attach module to optional display images in bodies.
new theme_image_attach_body($node) modified:
function theme_image_attach_body($node){
if (variable_get('image_attach_body', 1)){
drupal_add_css(drupal_get_path('module', 'image_attach') .'/image_attach.css');
$image = node_load($node->iid);
$info = image_get_info(file_create_path($image->images['thumbnail']));
$output = '';
$output .= '<div style="width: '. $info['width'] .'px" class="image-attach-body">';
$output .= l(image_display($image, 'thumbnail'), "node/$node->nid", array(), NULL, NULL, FALSE, TRUE);
$output .= '</div>'."\n";
}
return $output;
}
new image_attach_admin_settings() modified
function image_attach_admin_settings() {
$form = array();
$form['image_attach_existing'] = array(
'#type' => 'radios',
'#title' => t('Attach existing images'),
'#default_value' => variable_get('image_attach_existing', 1),
'#options' => array(0 => 'Disabled', 1 => 'Enabled'),
'#description' => t('When enabled, will allow existing image nodes to be attached instead of uploading new images.')
);
$form['image_attach_body'] = array(
'#type' => 'radios',
'#title' => t('Attach existing images on body'),
'#default_value' => variable_get('image_attach_body', 1),
'#options' => array(0 => 'Disabled', 1 => 'Enabled'),
'#description' => t('When enabled, will show the attached image to body.')
);
return system_settings_form($form);
}
sorry also for my horrible english.
| Comment | File | Size | Author |
|---|---|---|---|
| #13 | image_attach.module_135801.patch | 5.68 KB | drewish |
| #12 | image_attach.imagesizes.patch | 5.08 KB | psicomante |
| #10 | img_attach.image_size.patch | 5.36 KB | psicomante |
| #5 | img_attach..image_size.patch | 3.27 KB | psicomante |
Comments
Comment #1
drewish commentedyou english is fine, though you didn't submit a proper patch. see http://drupal.org/patch for more information. not submitting your changes as a patch makes it hard to tell what you're doing. by the look of it, i wonder if this patch is covered by: http://drupal.org/node/73854
Comment #2
psicomante commentedi will submit a patch, but that issue you linked to make the weight image configurable per node. It isn't a global configuration for ALL images.
Do you think that will be committed? Is it very useful.
Comment #3
drewish commentedsubmitting a patch makes it easier for me to understand what's going on with your changes. it probably won't be committed unless other people express an interest because i can't see the purpose. you could do the same thing by overriding the theme function.
Comment #4
psicomante commentedHow can i ovverride the theme function? What should i add to the template.php?
Comment #5
psicomante commentedi've made a little patch. I'm not sure if it is stable to use the <none> string :)
Comment #6
drewish commentedthat other patch got committed so i think this is fixed.
Comment #7
drewish commentedoh, i misunderstood the purpose of the patch.
you shouldn't be using a textfield, use a select. call _image_get_sizes() to get a list of the sizes to put into the drop down.
Comment #8
drewish commentedalso, you've got tabs in that patch, replace them with spaces.
Comment #9
psicomante commentedThanks drewish, i will modify the patch soon. Sorry for these errors.
Comment #10
psicomante commentedThis patch couldn't be useful for all people. It creates two new variables for every node you enable image_attach. You could get a bit slower site if you have a lot of content types.
I'm thinking about a good uninstall function for all these variables stuff :)
Comment #11
drewish commentedlooking much better. there's still some issues with inconsistent indenting. also since _image_attach_get_size_label() is only called from one place, don't bother making it a function at this point. just move that code back into the form.
a hook_uninstall wouldn't be a bad idea.
Comment #12
psicomante commentedThanks for the guidelines. I have so much to learn :)
For the uninstall hook i don't know how implement "deleting variables for all nodes". I think the better solution is using regexp, but i'm not so sure.
Here is the last patch. I hope this is correct.
Comment #13
drewish commentedokay, made some small changes to your patch but i really like it. i think it'll make a lot of people happy.
Comment #14
drewish commentedokay, since the odds are, no one will review this i'll just commit it and wait for bug reports.
thanks for all your hard work on this Psicomante.
Comment #15
psicomante commentedThanks drewish. It would be great add uninstall info to the module. If a user has a lot of node types, drupal will crate a lot of records in variables table. So that would be erased if you want to uninstall the module.
Sorry for my ugly and uglier english :P and Thanks to have committed the patch!
Comment #16
drewish commentedPsicomante, it's true, there are a lot of left over variables but that's an issue for a separate patch. feel free to open it ;)
Comment #17
(not verified) commented