WordPress.org

Ready to get started?Download WordPress

Forums

Add From Server
[resolved] Solution: Incorrect file URL in database after import (5 posts)

  1. denderli
    Member
    Posted 3 years ago #

    I came across a problem while using this plugin. I was importing some files that were already within the wp-content/uploads directory structure but were nested a couple of directories deeper. The files imported just fine into the media library and the correct URL for the file showed up in the media library as well.

    However, when trying to embed the file in a page or post for playback the file could not be found. Below is what I found and also a fix to correct the problem.

    Imported URL as seen by the media library:

    http://localhost/wordpress/wp-content/uploads/artist_name/sectiontitle/special_module_1_files/audio.mp3

    The actual URL as it had been saved to the database:

    http://localhost/wordpress/wp-content/uploads/audio.mp3

    The "fix" for this is a very simple one.

    Locate the file: add-from-server.php

    If you have a good code editor the code can be found at lines 207 and 208.

    If you don't have a good editor, do a search for the following:

    // Compute the URL
    $url = $uploads['url'] . '/' . rawurlencode($filename);

    Comment out the second line as such...

    // Compute the URL
    //$url = $uploads['url'] . '/' . rawurlencode($filename);

    Save your file and your URL's that are entered into the database will retain their original path. I haven't tested this for files that lie outside of the wp-content/uploads directory, but this resolved my issue.

  2. denderli
    Member
    Posted 3 years ago #

    Author's Note:

    This will not correct URL's that already exist in the database. You will either have to do that manually, or remove the database entry and re-import.

  3. denderli
    Member
    Posted 3 years ago #

    Author's Note:

    Alternatively, you could use this wonderful plugin to aide you in correcting the url's in the guid and meta_value fields.

    Search and Replace:
    http://wordpress.org/extend/plugins/search-and-replace/

  4. anarchtica
    Member
    Posted 3 years ago #

    I can confirm this problem exists and that the fix works.

  5. Dion Hulse
    WordPress Dev
    Plugin Author

    Posted 3 years ago #

    I believe this was fixed in 3.2.0.1, Specifically GUID's were receiving the incorrect URL's. Any plugin relying upon GUID's to determine the filepath is broken to start with..

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic