jtsternberg / DsgnWrks-Instagram-Importer

Backup your instagram photos & display your instagram archive. Supports importing to custom post-types & adding custom taxonomies.
http://wordpress.org/extend/plugins/dsgnwrks-instagram-importer/
33 stars 16 forks source link

Include videos by default #44

Closed nfriedly closed 6 years ago

nfriedly commented 6 years ago

I think that this plugin should include the video in the post by default when it imports from instagram. I know https://gist.github.com/jtsternberg/b7c3b5371c6f639693b8f086859ad129 exists, but I feel like that shouldn't be necessary, and it doesn't give any straightforward way to stick the video into e.g. the middle of the post.

I think we should add some new tags like **insta-video** and maybe a **insta-video-or-image** that would insert one or the other but not both.

Additionally it might make sense to have content-type conditionals such as [if-type-image] and [if-type-video] (and, eventually, an [if-type-carousel] - see #43).

Or, alternatively, different templates for different types.

nfriedly commented 6 years ago

Hey, @jtsternberg: I've been thinking about this for a couple of days, and I wanted to hear your thoughts before I go to far on an implementation.

To fully support videos and carousels in the template, I think we'd need these additions:

The default template would then look something like this:

[if-type-image]<p><a href="**insta-link**" target="_blank">**insta-image**</a></p>[/if-type-image]
[if-type-video]**insta-video**[/if-type-video]
[if-type-carousel][foreach-carousel-item]
  [if-type-image]<p><a href="**insta-link**" target="_blank">**insta-image**</a></p>[/if-type-image]
  [if-type-video]**insta-video**[/if-type-video]
[/foreach-carousel-item]
<p>**insta-text**</p>
[if-insta-location]<p>Photo taken at: **insta-location**</p>[/if-insta-location]
<p><a href="**insta-link**" target="_blank" class="instagram-link">View in Instagram ⇒</a></p>

However, this is starting to get a little complex, and I'm starting to think that we've reached the point where it might make sense to just use a third-party templating language & library instead of implementing all of the above ourselves. I don't have any particular one in mind, and I don't have a strong opinion on it; what do you think?


Oh, and one other thing that crossed my mind and is vaguely related to this: It'd be nice to provide the ability to re-apply an updated template to existing posts. I think we'd need to save the original instagram text in a meta field, and the order of the attachments for carousel posts. Is there anything else we'd need?

nfriedly commented 6 years ago

One more followup thought: perhaps we could simplify [foreach-carousel-item] to just [foreach-item] and let it run as a "loop" over the single item on image/video posts.

That would simplify the default template a bit by allowing the it to skip the first two lines and the condition on the third line:

[foreach-item]
  [if-type-image]<p><a href="**insta-link**" target="_blank">**insta-image**</a></p>[/if-type-image]
  [if-type-video]**insta-video**[/if-type-video]
[/foreach-item]
<p>**insta-text**</p>
[if-insta-location]<p>Photo taken at: **insta-location**</p>[/if-insta-location]
<p><a href="**insta-link**" target="_blank" class="instagram-link">View in Instagram ⇒</a></p>

I think that certainly feels a little more friendly and DRY.

We could still keep the conditionals for more advanced usage, but I think this feels like a better starting place. (I think this also makes sense with a third-party templating library.)

nfriedly commented 6 years ago

Oh, and it just occurred to me that you got hit by a hurricane last week. Sorry for hitting you with a wall of stuff in that context, this all can wait.

jtsternberg commented 6 years ago

I like your thoughts on this, but will introduce more mental overhead when trying to setup the importer settings. If we implement this, I think it would likely be best if we setup a wiki on this repo and link to it from the plugin for help with advanced options. Honestly, this is something I should do either way.

Let me know if you'd like to submit a PR for this.

nfriedly commented 6 years ago

Yea, I started working on this with twig 1.x (because 1.x supports all of the old versions of PHP that wordpress does), but I don't have it in a working state yet.

I think that's probably going to be the way to go, if it proves too difficult (or to have many conflicts with other WP modules), then I'll drop twig and work on improving the hand-rolled template system.

jtsternberg commented 6 years ago

I'm still up for twig-type things, but I couldn't wait as I needed the media-type conditionals for my own blog.