Wordpressで画像のサムネイルを後付けで設定するために実際に実行したSQL文。なお、動作についてはいっさい保証できません。
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
MariaDB [hoge]> update wp_posts set post_content=regexp_replace( | |
regexp_replace(post_content, | |
'(<img src=.*wp-image-(\\d+)[^>]*>)', | |
'<a href="https://pandanote.info/?attachment_id=\\2" rel="attachment wp-att-\\2">\\1</a>'), | |
'(?:(<a href[^>]*>))+(<img[^>]*>)(</a>)+', | |
'\\1\\2\\3') | |
where post_status = 'publish' and post_type='post'; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment