wp-shortcake / image-shortcake

Inline images as shortcodes for greater programmatic control over output
31 stars 7 forks source link

Explore creating an image shortcode with an external image #30

Open goldenapples opened 9 years ago

goldenapples commented 9 years ago

In a few places, the code is written as though its possible to create a shortcode using an external image rather than an attachment post. This functionality is not built out and poses a lot of problems, though.

We should scope out whether this is a reasonable/desirable feature and either build it out some more or remove the stub code which was written with that possibility in mind.

I suspect that this is not a feature worth building, as WP's media sideloader is already a pretty good experience.

vralle commented 8 years ago

https://gist.github.com/vralle/be30857d8c1f3bd55efa Insert external images as Shortcode by WP Media. WP4.4b4, work!) But shortcode UI need more change

goldenapples commented 8 years ago

A few thoughts about this gist: ^

This is just inserting all attributes from the <img> tag onto the [img] shortcode. That much makes some sense. The bigger question as I see it is how to represent that in the UI.

Right now, the UI has an attachment picker attribute defined for attachment, but no field defined for src. So you can insert a shortcode like [img src="http://src.url/filename.ext"], and it'll display fine with the callback, but if you try to edit it, the field for src won't be visible. Does it make sense to expose that field in the UI, and if so, when? Should we show a field for src unless there's an attachment selected?

vralle commented 8 years ago

The initial interface should meet the two fields. This attachment and src. When we select one, js can open only the required fields. It is not difficult. The difficulties begin, if we do not lose the opportunity WP Media. In this case, we would have to reinvent the wheel, catching up with WP Media. On the other hand, if we have a shortcode like in other places, we have to do something with it.

The solution is to reverse [img src = "link"] to html via the filter 'content_edit_pre'. In this case, we can use the WP editor. When save the entry, we can convert html to shortcode again

PS. I apologize if my English is not good.