• I’ve noticed that meta data associated with the jpeg still attachments created by your plugin contains absolute (full) file paths with a double slash in.

    The reason for this is that the still path that you generate (in extract_first_frame) accidentally has one of the forward slashes in the path doubled up, and as such when you make the call to store the attachment via wp_insert_attachment then it thinks that the location of the file is not in the standard uploads directory and as such it stores full file path locations (with the doubled slash) rather than ones relative to the uploads directory.

    So e.g. if your home directory for your wordpress install is /home/wpuser/my-wp-site/ then the meta information for the still images generated by your plugin about the still file locations will start /home/wpuser/my-wp-site//wp-content/uploads/

    The reason for this doubling is because home_url() doesn’t have a trailing slash whereas ABS_PATH does. So this line:
    $new_still_path = str_replace( home_url(), ABSPATH, $new_still);

    Needs to be:
    $new_still_path = str_replace( home_url() . ‘/’, ABSPATH, $new_still);

    With that change then wordpress correctly stores just the bit of the path relative to the uploads directory for the still image.

  • The topic ‘Bug in path generated for stills – doubled slashes and absolute paths’ is closed to new replies.