• I found bug about posts update.
    Moving files O.K.

    Thre are short name files in my site.
    Ex.) 1.jpg, 2.png

    This plugin updates content of posts by MySQL replace function.
    From $search_url to $replace_url php vars.
    But $search_url and $replace_url was removed file extension.
    So many posts match, then replace.

    I tried this:

    
    ...
    class OrganizeMediaLibrary {
    ...
      function regist($re_id_attache, $target_folder, $character_code){
        ...
        $search_url = str_replace('.'.$ext, '', $url_attach);
        $replace_url = str_replace('.'.$ext, '', $new_url_attach);
    
        // ↓modify
    
        $search_url = $url_attach;
        $replace_url = $new_url_attach;
        ...
    
    

    I think its O.K.

    Is there any reason for remove file extension?

    Thanks.

    • This topic was modified 7 years, 2 months ago by hisu.
    • This topic was modified 7 years, 2 months ago by hisu.
Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Author Katsushi Kawamori

    (@katsushi-kawamori)

    Thanks your report !!

    Plugin Author Katsushi Kawamori

    (@katsushi-kawamori)

    Removing file extensions is to replace each thumbnail.

    Example

    2017/09/1 -> test/1
    2017/09/1-150x150.jpg, 2017/09/1.jpg -> test/1-150x150.jpg, test/1.jpg
    Thread Starter hisu

    (@hisu)

    Hi, Katsumi.

    > Removing file extensions is to replace each thumbnail.

    I see, but I think it is not good.

    I tried this:
    * All media items, January 2010, / -> [Filter]
    * Result
    * 1.jpg
    * Select file, set Folder to 2010/01, Move to selected folder -> [Apply]

    Result:

    
    ----
    before (files)
    ----
    date    path
    2010/01 /1.jpg
    2010/01 /1-150x150.jpg
    20xx/xx /11.jpg
    20xx/xx /11-150x150.jpg
    20xx/xx /111.jpg
    20xx/xx /111-150x150.jpg
    
    ----
    before (post contents)
    ----
    /1.jpg
    /1-150x150.jpg
    /11.jpg
    /11-150x150.jpg
    /111.jpg
    /111-150x150.jpg
    
    ----
    after (files)
    ----
    date     path
    2010/01 /2010/01/1.jpg
    2010/01 /2010/01/1-150x150.jpg
    20xx/xx /11.jpg
    20xx/xx /11-150x150.jpg
    20xx/xx /111.jpg
    20xx/xx /111-150x150.jpg
    
    ----
    after (post contents)
    ----
    OK /2010/01/1.jpg
    OK /2010/01/1-150x150.jpg
    NG /2010/01/11.jpg
    NG /2010/01/11-150x150.jpg
    NG /2010/01/111.jpg
    NG /2010/01/111-150x150.jpg
    

    This plugin get filenames of thumbnail by wp_get_attachment_metadata() function, then use those filenames to move thumbnail files.
    So files correctly move.
    I think you can use sama filnames to replace post contents. ($current_thumb_file, $target_thumb_file php vars)
    Then no need to remove extensions for replace post contents.

    Thanks.

    Thread Starter hisu

    (@hisu)

    Hi, Katsushi.
    Sorry, I made a mistake your name.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘bug: replace incorrect many posts’ is closed to new replies.