Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

support multiple og images #11

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open

support multiple og images #11

wants to merge 2 commits into from

Conversation

lekoala
Copy link

@lekoala lekoala commented Jan 26, 2017

this is a small patch to handle arrays from getOGImage

if getOGImage returns an array, handle it gracefully
@jonom
Copy link
Owner

jonom commented Mar 23, 2017

@lekoala I don't follow why getOGImage() should be able to handle an array? The method name implies a singular resource and OG only supports a single image per URL.

Thanks for the PR but I think that this is something you could solve in your own projects instead of this module by applying the logic you've used here in your own getOGImage() function.

If I've misunderstood the intention here feel free to re-open or add a comment!

@jonom jonom closed this Mar 23, 2017
@lekoala
Copy link
Author

lekoala commented Mar 23, 2017

I assume this module is made to be compatible with https://github.com/tractorcow/silverstripe-opengraph
If you look there, you will see that the method getOGImage can return multiple images that will be represented by multiple og:image tags (as it should be, according to the docs https://developers.facebook.com/docs/sharing/opengraph/object-properties)

You can include multiple og:image tags if you have multiple resolutions available. If you update the image after publishing, use a new URL because images are cached based on the URL and might not update otherwise.

so basically, it would be great to support this feature in your module. My pull request is not perfect as it only takes into account the first image, but what would really be great is to actually support array from og image and make some kind of slider into the preview.

@jonom jonom reopened this Mar 23, 2017
Copy link
Owner

@jonom jonom left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay, in that case could you make a couple of tweaks and then it looks good. Thanks

<p class="share-care-description">$OGDescription</p>
</div>
</div>
<div class="share-care-preview">
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please use tabs for indentation on html files

*
* @return string
*/
public function getMainOGImage()
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you change this to getFirstOGImage? I feel like that's more descriptive and less likely to confuse me later.

@jonom
Copy link
Owner

jonom commented Mar 23, 2017

Side note, do you know if 'multiple resolutions' means multiple resolutions of the same image? That would be my assumption, but would be interesting if instead you can supply a variety of different images for sharers to choose from... Is that what you're implying regarding the slider comment? Do you know if Facebook or other sites lets you choose from a range of images if you supply more than one image OG tag?

@lekoala
Copy link
Author

lekoala commented Mar 24, 2017

actually, that's how I used it : to allow choosing between multiple images. I discovered the actual documentation from Facebook when you asked about my changes :-)
So even if it seems that this is made from the same image in multiple resolutions, it can actually be used to provide multiple images that are not the same.

I'm working on the project that require this feature in one week or two I'll update the pull request at that time

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants