Hi All,

Done alot of reading about this through the forums and tried what has been suggested to no avail.

I have a brand new installation of drupal 4.7 with imagecache and imagefield installed. I have modified the .htaccess to what it should be

SetHandler Drupal_Security_Do_Not_Remove_See_SA_2006_006
Options +FollowSymlinks
#RewriteEngine off

Ive uploaded photos(imagefield cck) and they just appear in the root of the files folder. Ive added imagecache presets/rules and they dont appear in the views image field options. It seems to be the .htaccess thing but that is correct and now I've run out of ideas. I installed the image.module and that put the options in the views image field options ok but do not want to use that module so I've disabled it. I run ubuntu dapper with apache2 and php5.2

I added the print theme function in the node.tpl files but that does squat as the imagecache directory is created. Is this only done on the fly when someone tries to access the originial photo? I would imagine imagefield sets everything up when the image is loaded in the first place.

Any help would be appreciated.

Cheers

Mike

Comments

intervalle’s picture

imagecache don't creates the filedirectories under "files" ... any ideas?

ore’s picture

I got mine going in the end.

The big problem I was having was I hadnt configured the mod rewrite properly. you need the -f for files so make sure you have everything as in the readme and all the other examples and then your mod rewrite settings in your apache should look something like this ( this is exactly what i have in mine )

 RewriteEngine on
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?q=$1 [L,QSA]
macm’s picture

in Readme of imagecache: "...and comment out Rewrite Engine off with a # at the beginning of the line."
so I change my .htaccess to
# RewriteEngine on

So ore Why you are using "RewriteEngine on" without # in the begin?

After create "Imagecache Presets" nothing change.

I read a good tutorial in
http://www.lullabot.com/articles/image_and_image_exact_sizes_vs_imagefie...

said

<?php
 print theme('image', 'files/imagecache/product_images/'. $node->field_product_image[0]['filepath']); 
?>

Where "product_images" is "Imagecache Presets" name So I thought why my drupal dont create a new directory?

About the code

  <div class="node<?php if ($sticky) { print " sticky"; } ?><?php if (!$status) { print " node-unpublished"; } ?>">
    <?php if ($picture) {
      print $picture;
    }?>
    <?php if ($page == 0) { ?><h2 class="title"><a href="<?php print $node_url?>"><?php print $title?></a></h2><?php }; ?>
    <span class="submitted"><?php print $submitted?></span>
    <span class="taxonomy"><?php print $terms?></span>
    <div class="content">
<?php
// Rather than printing $content, we can print fields individually.
print '<p>'. $node->field_description[0]['view'] .'</p>';
// Here we're printing out the imagecache-manipulated image.
print theme('image', 'files/imagecache/mypresetnamespace/'. $node->field_primary_image[0]['filepath']);
?>
    </div>
    <?php if ($links) { ?><div class="links">&raquo; <?php print $links?></div><?php }; ?>
  </div>

I created node-content_my_cck_type.tpl.php into my "my_cck_type " I created "description" field and "primary_image" field
I receive my call of "field_description" but my image still missing

Why 'files/imagecache/mypresetnamespace/' IF doesnt exist?

What is 'image' in "print theme('image',....."
What is 'filepath' in "....ge[0]['filepath']);"

But I didnt stop and I went to View module and after new view was created my image still missing. Something is missing in imagecache documentation.

Anyone have this modules working together CKK, imagecache and view could help because I saw some websites working well.

Please help us!

ore’s picture

Ok first off,

My .htaccess is exactly like this.

SetHandler Drupal_Security_Do_Not_Remove_See_SA_2006_006
Options +FollowSymlinks
#RewriteEngine off

the # is used to comment out that field.

Check to see if mod_rewrite is enabled by going to settings->general->settings in drupal admin, then perform the clean url-test. If you have this then mod_rewrite is working. Now hopefully yours has the -f configured in apache already (mine didnt which was what my problem was). So in the config for my drupal site I put a directory control in with these exact settings.

RewriteEngine on
        RewriteBase /
        RewriteCond %{REQUEST_FILENAME} !-f
        RewriteCond %{REQUEST_FILENAME} !-d
        RewriteRule ^(.*)$ index.php?q=$1 [L,QSA]

These go in apache configuration file for your domain name (if your running virtual hosts). If your using a hosting company then tell them to turn those on for your hosting.

Now the filesystem is setup. So now activate your imagecache module (if you havnt done so already) now goto imagcache and create a preset called "thumbnails" - > I use scale and just set a height.

Now all you need to do is add this in your node.tpl.php or the custom one you have created.

theme('imagecache', 'thumbnails',$field_photo_1[0]['filepath'] );

imagecache - > this is the name of the directory that will be created, the code creates a menu call back and when it sees this starts up the imagecache engine to process the images (first time it does a lot more work than the next times). So keep it named image cache

thumbnails -> this is the name of your preset, so if you have two then you change this to next preset you create, ie previews for a bigger size

field_photo_1 -> this is the name of the imageready field you use to upload the image you want to change the size of. the [0] on the end of it means its the first value. drupal can hold multiple values per field. You can find out the name of the field by going to content -> content types-> then click your custom content type -> manage fields , you will see your imagefield name there. filepath is the filepath for that photo field uploaded by imagefield. You dont alter this.

Check you are actually using the correct node.tpl.php or variation by adding var_dump($node); in your code (must go in tags ) and then you will see a whole lot of fields output then you know you are in the correct file.

The images should get displayed now. If not check the files directory can be written to. Thats pretty much all there is to it.

Hope all this helps.

Mike

macm’s picture

Thanks a lot

Now I am trying config my localhost and my webhost to use clean Url's
Just one more question about

RewriteBase /

If I am using localhost what I need to do?

RewriteBase /mydir
or
RewriteBase localhost/mydir/
or
RewriteBase http://localhost/mydir/

RewriteEngine on
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?q=$1 [L,QSA]

Is drupal .htaccess?

Best Regards

Mario

adminzen’s picture

This (the .htaccess) fixed my problem as the server was in Safe Mode and was not creating directories (eg: /tmp). This solution bypasses the write protection of the server itself. Thank you so much!!

My Solution was to change the /tmp directory to:
/sites/default/files/tmp/

and place Ore's .htaccess modifications in that directory. After I went to Admin > File Access and specified this (/sites/default/files/tmp/) as the new /tmp directory, it gave me no problems--even in safe mode!

Thank you so much Ore.

Shai’s picture

This is a long and arduous thread that I came to because I seemed to have the same problem.

I solved my problem by simply setting up the needed tmp directory via the file system configuration screen:

http://example.com/admin/settings/file-system

Shai

content2zero.com

cog.rusty’s picture

If I may add my 2c, because I found some points in this discussion unclear, this is how it is supposed to work:

1. The .htaccess file in drupal is supposed to stay the way it is, except if there is a reason to change something.

2. The .htaccess file under your files directory must contain only those two lines:
SetHandler Drupal_Security_Do_Not_Remove_See_SA_2006_006
Options +FollowSymlinks

3. Your files directory (the one which you have specified in your general settings) must exist and must be writable by all (777).

Normally, the "#RewriteBase" line in drupal's .htaccess should stay disabled as it is, with the # in front.
(All settings are done with the settings.php and with its directory name under /sites.)
Only if for some reason clean URLs do not work with this setup, then you try to change it to "Rewritebase /mydir" and remove the #.

macm’s picture

Ok Thanks a lot

Now I am runing Clean Urls.

I followed all steps to make imagecache works.

I followed this tutorial
http://www.lullabot.com/articles/image_and_image_exact_sizes_vs_imagefie...

Everythings work well less PRINT IMAGECACHE

I created description field in mycckcontent and I can print this field but imagecache of my imagecck not. (:

I run

<?php
var_dump($node)
?>

and received

object(stdClass)#13 (5) { ["nid"]=>  
string(1) "7" ["node_data_field_imagecck_field_imagecck_fid"]=>  
string(1) "6" ["node_data_field_imagecck_field_imagecck_title"]=>  
string(0) "" ["node_data_field_imagecck_field_imagecck_alt"]=>  
string(0) "" ["node_data_field_description_field_description_value"]=>  string(66) "test" }

imagecck is my field

So my code is

<?php
print theme('imagecahe', 'mypresetnamespace', $field_imagecck[0]['filepath'] );
?>

If I change my views to default unless mypesetnamespace I can see my image

What is missing?

I think that I followed all steps.

I went to my log page and I have this error messages

Type php
Date Tuesday, November 14, 2006 - 20:51
User Mario Moura
Location ...localhost/mydrupalinstallation/files/imagecache/mypresetnamespace/files/mario1c.jpg
Referrer http://localhost/mydrupalinstallation/admin/logs/event/921
Message fopen(files/imagecache/mypresetnamespace/files/mario1c.jpg) [function.fopen]: failed to open stream: No such file or directory in C:\wamp\www\mydrupalinstallation\includes\file.inc on line 561.
Severity error
Hostname 127.0.0.1

Type php
Date Tuesday, November 14, 2006 - 20:51
User Mario Moura
Location ...localhost/mydrupalinstallation/files/imagecache/mypresetnamespace/files/mario1c.jpg
Referrer http://localhost/mydrupalinstallation/admin/logs/event/921
Message filesize() [function.filesize]: stat failed for files/imagecache/mypresetnamespace/files/mario1c.jpg in C:\wamp\www\mydrupalinstallation\modules\imagecache\imagecache.module on line 142.
Severity error

Type php
Date Tuesday, November 14, 2006 - 20:51
User Mario Moura
Location ...//localhost/mydrupalinstallation/files/imagecache/mypresetnamespace/files/mario1c.jpg
Referrer http://localhost/mydrupalinstallation/admin/logs/event/921
Message getimagesize(files/imagecache/mypresetnamespace/files/mario1c.jpg) [function.getimagesize]: failed to open stream: No such file or directory in C:\wamp\www\mydrupalinstallation\modules\imagecache\imagecache.module on line 139.
Severity error

ore’s picture

It seems you are doing things correct to me except that you are using windows ;) I tried using drupal and imagecache on windows the other day and had no luck with the files directory. It kept making the directory read only. So I just gave up and went to linux. I'm sorry this is not of help to you. Try right mouse clicking on the files directory and see what the permissions are. Mine were read only and everytime i changed it to write it would revert back again.

cog.rusty’s picture

See this

http://support.microsoft.com/default.aspx?scid=kb;en-us;326549

Read only directories do not really exist in windows, only files. That attribute is used for other purposes and although you could change it using a DOS command that wouldn't make it any more writable than it was for Windows.

Usually there is another problem.

cog.rusty’s picture

Does your mario1c.jpg file really exist in the folder where the messages say it should be?

-----

Edit:
Check the imagecache issues. There are a couple issues there which might be related.
http://drupal.org/project/issues/imagecache

Also check this drupal issue about Windows, PHP and file uploads.
http://drupal.org/node/91624

macm’s picture

No

the file mario1c.jpg exist in ...localhost/mydrupalinstallation/files/
and not in ..localhost/mydrupalinstallation/files/imagecache/mypresetnamespace/files/mario1c.jpg

But after read some documentation about imagecache I think it is correct.

Thanks for reply

Best regards

Mario

macm’s picture

Hi

Sometimes in new installation Why mypresetnamespace dont appear in options of Views module? After follow all steps of course! Am I missing something?

baronmunchowsen’s picture

I've been pulling my hair out for days trying to figure out why my image cache "wasn't working". As is often the case, it wasn't the module - it was me. I only hope the information I am about to impart will save others from going insane!

My situation: I run Apache, MySQL(5) and PHP on my Windows XP machine for development - I find it quicker. I've only started doing this recently. I move the site to my webhost which is a LAMP setup when it's pretty much there.

I couldn't get imagecache to work (image files weren't appearing in the directory they were supposed to).

Problem - I hadn't altered my temporary files path in administer->site configuration->File system. It still read 'c:\temp' which should have been '/tmp' . I am a buffoon.

joeboris’s picture

From a fellow buffoon!

btoland’s picture

I was following one of the really great articles over on lullabot and ran into some grief with imagecache on 5.2 - my new images were not being created.

Basically my problem was that I had placed my "files" directory outside my webroot and called it drupal_files. i.e. I had drupal_files at the same level as mysite.com.

This caused me lots of grief and my new images were not being created. Solved my moving my file system back to using a files directory inside my webroot e.g. mysite.com/files.

I had read in some article somewhere or heard in some podcast that it was "more secure" to place your files directory outside your webroot directory. I duly followed this advise and all was well until I started trying to use imagecache and my new files were not being created.

As I can configure my files directory to be wherever I like (and called whatever I like) in the admin interface is it perhaps a bug in imagecache that it will only work with the files directory at the default location/name? I pose this as a question as there is a good chance that I was simply doing something basic incorrectly... perhaps I didn't form the URL to the new image correctly... although no imagecache directory was created in my drupal_files....

Anyway, with my file system at mysite.com/files it all works - imagecache has created a new directory in my mysite.com/files directory with all the required sub-directories and resized images required.

I must admit I have found finding good documentation on imagecache and it's setup hard to find...

Hope this info helps somebody else!

cog.rusty’s picture

Imagecache says in its project page that it requires
- public files
- clean url support

So, if you were using the "private download method" to access the files outside the webroot through Drupal, imagecache wouldn't work.

If your files were not really outside the webroot -- just outside Dupal

public_html/site (Drupal here)
public_html/files

and you were using the "public download method", having set your files directory to "../files" in Drupal, then I don't see why imagecache would object.

This is just theory. I haven't really done it.

amigob’s picture

Windows XP
apatche 2.2.4
msql 5.0
php 5.2.3
drupal 5.2
phpbb module for phpbb3
imagecache 1.3

I had the same problem. And I am working now for 3 days on getting the imagecache to work on my site. I did every thing I found on the drupal site to get it working.
attrib -r \D \s ' drupal directory'
setting temp directory to 'tmp' ( this is now in my drupal directory )
checked all the .htaccess files
and nothing worked. To day I found that with the integration of phpbb I changed the .htaccess file of the forum, to

<IfModule mod_rewrite.c>
  RewriteEngine on
  # Modify the RewriteBase if you are using Drupal in a subdirectory and
  # the rewrite rules are not working properly.
  #RewriteBase /

  RewriteRule ^inbox$           ucp.php?i=pm&folder=inbox [L]
  
  RewriteCond %{QUERY_STRING} ^mode=login(.*)$
  RewriteCond %{QUERY_STRING} !^bypass=true(.*)$
  RewriteRule ^ucp.php(.*)$ ../phpbb/login [L]
  
  RewriteCond %{QUERY_STRING} ^mode=register(.*)$
  RewriteRule ^ucp.php(.*)$ ../user/register [L]

  RewriteCond %{QUERY_STRING} ^mode=logout(.*)$
  RewriteRule ^ucp.php(.*)$ ../phpbb/logout [L]
  
  RewriteCond %{QUERY_STRING} ^mode=sendpassword(.*)$
  RewriteCond %{QUERY_STRING} ^mode=resend_act(.*)$ [OR]
  RewriteRule ^ucp.php(.*)$ ../user/password [L]
</IfModule>

As written in the phpbb module install description. I remove this and it works fine.
The problem here is that the files directory is placed in the forum directory so that it can share avatars and files with the forum. The directory is :
'forum/shares'

I don't know much about .htaccess files, so the question what do I need to change to get the phpbb stuff back and have my imagecache still working ?

AmigoB

headkit’s picture

o.k. who is the guy then, who knows about .htaccess!? please stand up and tell us about it...

my problem is that I want to use image attach (and so cleanURLs) on my second site which is placed into the sites-folder and reached by a subdomain like "sub.main.com".
what should I write into the .htaccess????

cog.rusty’s picture

Normally you don't need to do anything. Drupal's default .htaccess file included in the package takes care of Clean URLs and image_attach doesn't need anything special. (Except if your .htaccess already contains modifications which complicate things.)

You only need to specify in Drupal's settings:
- in the /admin/settings/file-system page, where is the 'files' directory for each site,
- in the /admin/settings/image page, in which subdirectory under that is the images directory (notice what it says under that field about the images path).

What is happening with your second site when you are trying to use image_attach?

headkit’s picture

in the default-site, everything is fine now since I changed the .htaccess to

RewriteRule ^(.*)$ /CMS/index.php?q=$1 [L,QSA]

but in the sub-site, cleanURLs is not working.
that's because the sites URL "sub.main.com" is routed to the folder "sites/sub.main.com/" and there is a conflict because drupal searches a CMS-Folder there?

cog.rusty’s picture

Oh, you have done this trick.

Read the follow up changes in this thread: http://drupal.org/node/144643

You probably need to use two different RewriteCond/RewriteRule pairs for the two sites, making the rewrites depend on what URL the user asked.

Your rewrite must not happen if the user asks the specific URL of your second site. Details depend on what that URL is.

--------- Edit

No, forget this. I probably misunderstood. I don't even know if you are using two different installations or a single multisite, or what is the directory of your subdomain, or what is the error with image_attach for that matter.