wp print_thumbnail function is not working

前端 未结 4 808
离开以前
离开以前 2021-01-16 19:41

wordprees print_thumbnail function is working correctly on testing server but it\'s not working on online server and giving wrong image path such as */var/www/vhosts

4条回答
  •  深忆病人
    2021-01-16 19:49

    POSSIBLE FIX 2

    Look, I've seen this problem on other threads and on other websites and no one gave information that helped most of the people with this issue, so since I somehow got my broken site to work, perhaps it will help the others who did not get their problem solved.

    Here's a little background... I needed to move a wordpress site located on a dev server to the live server. They were different domain names of course. First of all, I should have followed Moving Wordpress instructions and updated the site url before I exported the database, but... I didn't because I'm obviously too cool for instructions.

    In order to transfer the site, I zipped up the files and transferred them to the new server and unzipped them. Then I edited wp-config and pointed it to the new database.

    I used phpmyadmin to export the old database and I imported it to the new database.

    Then I ran a query on the wp_posts table to do a string replace on the guid field and replace all instances of the old domain name with the new domain name.

    Then I checked in wp_options and changed 2 records to replace the old domain name with the new one. I think they were something like siteurl and home.

    Everything seemed to be working fine except the theme was mangling the img urls, prefixing them with the absolute filepath.

    I figured I must have missed some records in the database that give the print_thumbnail function whatever information it needs to output the right url for the img's src attribute.

    I thought if I could change a setting somewhere and change it back, maybe wordpress would automatically fix the issue for me, and I was lucky.

    I played around with several settings and what finally worked was:

    I went to Media Settings and I unchecked Organize my uploads into month- and year-based folders -- I don't know if this had much to do with the fix.

    I also changed the Store uploads in this folder to something like wp-content/uploads2. I never created that folder, but I just wanted to get it to overwrite whatever was controlling that value.

    I checked the site again and there was a change to the html source... now, it didn't even give the img tags a src value... it was just like , so I figured I was on the right track.

    So then I went back and changed Store uploads in this folder setting and left it blank as it was originally.

    After I did that, the img src values were correct.

    Hope this saves someone some time.

    Also, I should note, I played around with altering the file permissions for the wp-content directory. I wish I hadn't. I get the gist of file permissions, but I tend to try not to fool with them if I don't have to. Using Filezilla is a pain to change the file permissions because it takes forever. Unfortunately, as most clients, this one had a prior affiliation with their web host and refused to take my advice and host their site on a VPS that would be cheaper and allow me to use SSH and get work done much easier. I wonder if there's a fast way to chmod multiple files without ssh, I should look into that.

    Cheers,

    Will

提交回复
热议问题