Link to home
Start Free TrialLog in
Avatar of gpinzino
gpinzino

asked on

Drupal images do not display

I am a stone-cold beginner to Drupal. I have done some reading on the Drupal website and have seen some tutorials. I have a general sense about how Drupal works, but that’s about it.

I have been asked by a client to do some work on their Drupal site. The site is currently fully functional and well-behaved. I am told it is running Drupal 6. I have downloaded the site and database to my PC. I am using WAMPSERVER64 (Apache v 2.2.17, PHP v 5.3.3 and MySQL v 5.1.52) and want to do my testing and development locally before messing with the production site.

I have been able to get the website home page to display correctly, except there are several images which do not display. You can go to http://www.claim-il.org/ to view the page and follow along. On that page you will see 3 photos. None of these pictures display locally. Also, at the bottom of the page, you will see a purple text box with a Donate button. The button does not display either.

When I view the source code sent to the browser, I see that the file names for the 3 photos all have special characters (spaces, underscores or brackets) in their names. They are all also located in the same directory (/sites/default/files/images).

When I display the home page in my test site, the URL is http://localhost/claim/index.php. I have tried setting the $base_url to http://localhost/claim in /sites/default/settings.php, but it did not resolve the problem.

Since I downloaded the site from a working version, I suspect it is a local setting of some kind. Where do I go from here?
Avatar of Aaron Feledy
Aaron Feledy
Flag of United States of America image

Are you running your site in a sudirectory on your local machine? Something like http://localhost/mysite ? If so, the site is looking in the wrong place for the images. It is looking in localhost/sites/default/images. In this case, the fix would be to edit the pages and insert the correct paths.
Avatar of Hagay Mandel
Assumption: You do have a sub directory '/files/images/' in your default site (at 'sites/default', and that sub folder contains all the files as the one in the production site. If not, you must copy the files as well!
Look at the source code, and check the path of those images as rendered by Drupal. You'll be able to detect the erroneous path.
Avatar of gpinzino
gpinzino

ASKER

Arrow_1 and HagayMandel,
You are right that Drupal is looking in the wrong place. As I mentioned, I changed the $base_url setting to http://localhost/claim, but it has had no effect. The rendered page does not direct the browser to the claim subdirectory. The settings file I found is in sites/default/. Am I in the right place? What do I do to fix this?
SOLUTION
Avatar of Hagay Mandel
Hagay Mandel
Flag of Israel image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
I am tempted to raise this as a separate question, but my guess is that the current question and my new issue are related, so I will raise it here and hope everything is resolved in a single solution.

I cannot access anything other than the index (home) page. If I click on any menu link, I get a 404 error. For example, if I click on Services>Legal Services, I get the URL "http://localhost/claim/legal-services" and the 404 error message.

Also, if I try to go to localhost/claim/user or http://localhost/claim/?q=user, I get a 404 error, so I cannot even log in to admin. What now?
This problem of not being able to access anything but the home page seems to be fairly common. The complaint shows up on the Drupal Community page http://drupal.org/node/1654. It was suggested that the .htaccess file was missing. The file was, in fact, missing from my setup.

I could not find the .htaccess file on the client's website, so I tried adding the .htaccess file from the Drupal6 installation package. No luck. The problem persists. I have attached the file for your review. Could there be an issue with the .htaccess file settings?
.htaccess.txt
I get the URL "http://localhost/claim/legal-services" and the 404 error message.

Now what happens if you omit the '/claim' from the url?
HagayMandel,
The issue with not getting other pages, appears to be a problem in the .htaccess file related to clean urls. I found a suggestion on the Drupal community site to add "$conf['clean_url'] = 0;" to the end of the settings.php file to suppress clean urls. Now, it looks like I can access all pages on the site.

However, I still cannot access admin, nor do the images display correctly. Right now, I am highly confident that localhost/claim is the correct base url. If you have any further suggestions on how to regain access to admin or what should be changed in .htaccess to fix the clean url issue, they would be welcome. In the meantime, I will continue my efforts as well.
On the .htaccess file, did you try changing the rewrite base? These lines are near the bottom of the file.

  # Modify the RewriteBase if you are using Drupal in a subdirectory or in a
  # VirtualDocumentRoot and the rewrite rules are not working properly.
  # For example if your site is at http://example.com/drupal uncomment and
  # modify the following line:
  # RewriteBase /drupal

Also, whenever the images are where they are supposed to be and I can't see them it's because I have forgotten to set the page input type to full html.
Yes, I have changed the RewriteBase, but it has not fixed anything. As I said earlier, I have made the setting to turn off clean URLs and I can get to the other pages on the website, but still no images from the media folder. It seems obvious to me that I have some bad settings somewhere. They talk a lot in the Drupal community about problems with .htaccess, but I have not found specific code to fix the issue.

I'm also stuck on the access to admin. I can get to the user login page by using http://localhost/claim/index.php?q=user and I can log in, but when I click on administer, I get the message in IE that it cannot display the webpage. In Firefox, it says the connection was reset. Again, it sounds like a configuration issue. I am using the superuser login, user1, so I don't expect it to be a permissions issue.
In Drupal 6, there are references to the URL in many places. Did you try to go through the database and do a find and replace?
So replace:
http://www.claim-il.org/ 

with:
 http://localhost/claim/
?
This doesn't happen in Drupal 7, which is a HUGE improvement.
Or, I just thought of this. Does the working website have the module installed called backup and migrate? You could install it on the site, and then create a back up, then do a clean installation on your development server and make sure you install the backup and migrate module, and migrate it to your site.
Two excellent suggestions. I'll give them a try and report back tomorrow.
I went through the entire database and fouond URLs only in the files table. They are relative addresses, beginning with "sites/". Adding "claim/" to the beginning of the image addresses had no effect.

Alos, I took a look at the backup and migrate module. It only backs up the database, which I have already done. I don't think that will help here.

I am posting the issue on the Drupal community site. If I get any resolution to the problems, I will post it here.
But did you use the restore function in the backup and migrate module on your development site, using a backup made by the module in the working site?
I think perhaps the most recent updates to the backup and migrate module have removed all absolute references to pages, which is great.
Correct me if I am wrong, but I believe the backup and migrate module backs up only the database. I used phpMyAdmin to export and import the database. I believe I have an accurate copy of the database. Do you think it will do any good to try it again using backup and migrate? The module is not on the production site, and I am reluctant to do anything on the site without testing it first.
The name of the module includes migrate. I have used it to migrate to new servers and I have never had a problem with it. It is a very common module. Does the live website have a way to keep the site backed up on an ongoing basis? I always set up back up and migrate on sites and have it make backups as often as the website users think they will be making changes, once a month, or once every few days. It's a good module. Does the live site have any custom modules on it? If all the modules are regular Drupal modules, the backup and migrate module is perfectly safe.
Thanks, I'll give it a try.
If you are worried about it, backup the live site database using PHPMyAdmin or something first. But I use this module on every single site I have installed for clients to make regular backups of their site.
Well, it has been an interesting experiment to implement backup and migrate. Apparently, to be able to backup and migrate files in addition to the database, a second module, backup and migrate files, is required, plus the Archive_Tar class in PEAR. I won’t bore you with the painful details, but it looks like I need a PEAR file called Tar.php to place in the backup_migrate_files/includes directory.

When I followed the instruction in the backup and migrate files README file, I wound up with an xml file called Archive_Tar-1.3.3. I added that file to the includes folder under the Archive_Tar-1.3.3 filename as well as under the Tar.php name.

The backup function backs up the database as expected, but no options to back up the files show up. Dreamhost says a basic PEAR implementation is included on the server. I must be missing something, but I do not know what it is.
Today, I tried a fresh download of the database and files with basically the same results. Still needed to modify settings to access other pages, reset the base URL and turn off clean URLs. I also had to modify the default .htaccess file to change the RewriteBase.

I still have the same issues.
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
OK. I took my chances and made the changes directly on the production server, and held my breath. Fortunately, it worked. This is my second failed attempt at setting up a CMS locally. These tools are not as easy to use as their developers would have you believe.

I am awarding points based on your contributions to the effort. Thanks for your help.
While a final solution to the issues was not found, I learned a lot from the many helpful suggestions from the experts.