1

Is there a module that allows images to be uploaded and inserted in place, like in a block or something similar?

5 Answers 5

2

I think you're looking for the Insert module.

Here is the description from the Project page on Drupal.org

Insert is a utility that makes inserting images and links to files into text areas or WYSIWYGs much easier. It adds a simple JavaScript-based button to FileField and ImageField widgets. When used with ImageField and ImageCache, images may be inserted into text areas with a specific ImageCache preset.

1

you can read all images that uploaded in a folder using custom block

  $output = '';
  $directory = 'public://myfolder';
  $files = file_scan_directory($directory, '/.*/');

  foreach ($files as $file) {
    $output .= '
      <div>
        ' . theme('image_style', array('style_name' => 'thumbnail', 'path' => $file->uri)) . '
      </div>';
  }
return output;

but If you need only images to be displayed in a block you can use editor like ckeditor All u have to do to make the block description as full html and upload image using ckfinder or from url

3
  • 1
    I dont recommend this be written inside the block itself since a small error in your code could break your site, try placing this inside a custom module with "hook_block_info" and "hook_block_view"
    – saadlulu
    Commented Mar 8, 2012 at 15:12
  • nice piece of code but I want the admin to be able to Upload a header image and overwrite the existing image showing a new one. they want to be able to change the header easily which means they need a method to upload directly
    – acctman
    Commented Mar 8, 2012 at 15:56
  • ok you will need a ckeditor or you can make a view that display a certain cck with header image and text and make admin edit in this content type
    – Ahmed
    Commented Mar 9, 2012 at 18:59
0

Check the IMCE module. IMCE is an image/file uploader and browser that supports personal directories and quota.

1
  • this will allow in-place insert/changing of an image? I have a header image that I want to be easily switched out without the client having to go into FTP. so i'm looking for the simplest non-confusing method there is.
    – acctman
    Commented Mar 8, 2012 at 15:24
0

How I've done this is to create a content type called splash that has (at a minimum) two fields:

 1.  an image field, and,
 2.  a text field to be used as the path.

Set up permissions to allow whoever you want on your site to be able to create all the above.

If you don't want to create a module yourself, you can then use Views to create a block display that:

 1.  Filters on published nodes of type splash
 2.  Returns only 1 result
 3.  Sorts descending by node publish or modification date or however you want
 4.  uses the text field as an argument (or contextual filter) that
     a.  uses PHP to return a default argument:
         i)  return drupal_get_path_alias($_GET['q']);
 5.  uses the image field to display the image 

and then have this block displayed wherever you want your splash header displayed.

And provided my brain is engaged that should set you on a path that, when a user creates a node of type splash, they enter an image file to upload and a path that it should be displayed on (foo/bar/bazz, path/to/my/node, etc) on your site.

0

I had a similar problem for one of my clients: the problem was that it was too difficult for him to click 3 different buttons in order to upload an image. I searched a lot and finally I found the easiest and more straightforward solution in this question: Using ImageField to add an inline image.

It basically describes a way of inserting an inline image just by using a file upload field. You will predetermine where the image will appear and then the client will only have to press a button and select the image in his machine.

If you want to give your client the freedom to move around the image, you will also have to add some complexity to your approach. Which means that you will probably have to go with IMCE. But you can still make his/her life easier by using the Image Resize Filter to make Drupal automatically create the thumbnails when your user is graphically resizing the images. You can see the Image Resize Filter module in action in Lullabot's video or in Mustardseed's video

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.