-
Notifications
You must be signed in to change notification settings - Fork 7
Transform <img>
to [img]
on the fly with shortcode reversal
#38
Comments
My custom converter via DOMDocument: https://gist.github.com/vralle/1f9a79a42d0c35f3b00f |
The link above has added new code. |
@vralle - nice, thanks! There are a few things in there that I don't think we can really depend on in many production environments... like being able to query for all attachments at once and loop through them. But something along those lines will be necessary in order to get beyond the naive regex that we're currently using to match image tags to the attachment ids. I do also like the looping through the generated attachment sizes to try to match the filename of the img src to the filename of a specific crop size. I think we can probably do something like that in any migration/reversal script that lands in here. Do you have time to try and put together a pull request that does this? The pattern we've been following with Shortcake is to include a "reversal" function (stubbed out here, which is hooked onto |
Now the code is just a draft. It works, but it has a number of bottlenecks. The main bottleneck - is a request for all attachments. There is an idea to create a request in a separate function and put the result into the cache by the Transients API. This has a significant impact on performance. As I was not able to resolve the filter 'content_save_pre'. For unknown reasons, the first is used sanitize and does not depend on the priority specified for 'content_save_pre' |
down
now use 'edit_post_content' Need to more testing |
|
hmm. This is an interesting approach. So you have the post content converted into I don't think that's exactly what @danielbachhuber meant in the original issue. Since we're trying to build out an extensible UI for managing images, I think we'd rather use the Shortcake UI for managing images, and try to bring that into feature parity with the WordPress media UI, than just fall back to the WordPress UI. The issue here is that if we add new features to the A few specific thoughts on your code:
|
We should have some option for transparently converting
<img>
to[img]
on the fly using shortcode reversal when the post is saved.The text was updated successfully, but these errors were encountered: