PHPackages                             jonom/silverstripe-share-care - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. jonom/silverstripe-share-care

ActiveSilverstripe-vendormodule[Utility &amp; Helpers](/categories/utility)

jonom/silverstripe-share-care
=============================

Social media sharing previews and customisation for Silverstripe

v5.0.1(3mo ago)2932.7k↓39.1%14[3 issues](https://github.com/jonom/silverstripe-share-care/issues)1BSD-3-ClausePHP

Since Nov 6Pushed 3mo ago4 watchersCompare

[ Source](https://github.com/jonom/silverstripe-share-care)[ Packagist](https://packagist.org/packages/jonom/silverstripe-share-care)[ Fund](https://www.paypal.me/jmnz)[ GitHub Sponsors](https://github.com/jonom)[ RSS](/packages/jonom-silverstripe-share-care/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (10)Dependencies (3)Versions (21)Used By (1)

Share Care for Silverstripe
===========================

[](#share-care-for-silverstripe)

When URLs are shared on social media a rich preview of the content may be generated to give the URL context. The goal of this module is to encourage CMS users to be aware of how their content will appear when shared, and give them tools to customise this appearance.

[![CMS Preview Example](screenshots/share-care-cms.png)](screenshots/share-care-cms.png)

Requirements
------------

[](#requirements)

- Silverstripe ^6
- [Silverstripe Opengraph module](https://github.com/tractorcow/silverstripe-opengraph)

Installation
------------

[](#installation)

See the [Packagist listing](https://packagist.org/packages/jonom/silverstripe-share-care) and [composer installation instructions](http://doc.silverstripe.org/framework/en/installation/composer#adding-modules-to-your-project).

1. `$ composer require jonom/silverstripe-share-care`
2. Flush manifests by visiting /dev/build

Upgrading from v4 to v5
-----------------------

[](#upgrading-from-v4-to-v5)

- Rename `doClearFacebookCache()` to `shouldClearFacebookCache()` in your code if you have overridden this method.
- Default config value for `enable_facebook_cache_clear` has changed from `true` to `false`. Please update your configuration if you want to continue using this feature.

How to use
----------

[](#how-to-use)

### View rich share previews in the CMS

[](#view-rich-share-previews-in-the-cms)

With the module installed you should find a Share tab on all pages which shows you roughly what each page will look like when shared on social media. The preview is based upon the output of the Opengraph module, so your configuration of that module will be reflected here.

To add share previews to other DataObject classes, just add the `ShareCare` extension to them. Example:

```
---
Name: mysharecare
After: "opengraphextensions"
---
MyDataObject:
  extensions:
    - JonoM\ShareCare\ShareCare
```

See the [Silverstripe documentation](https://docs.silverstripe.org/en/developer_guides/extending/extensions/) for more info on extensions.

### Customise the appearance of content on social media

[](#customise-the-appearance-of-content-on-social-media)

You can configure the Opengraph module to generate open graph tags however you like, and this is what controls the appearance of rich previews on social media (especially Facebook and Twitter). To quickly configure the Opengraph module to allow CMS users to customise the content and appearance of these previews, just add the `ShareCareFields` extension to your Page class (and any other classes you like).

[![Field example](screenshots/share-care-fields.png)](screenshots/share-care-fields.png)

Example configuration:

```
---
Name: mysharecare
After: "opengraphextensions"
---
Page:
  extensions:
    - JonoM\ShareCare\ShareCareFields
```

This allows CMS users to customise the image, title and description that are shown when a URL is shared on social media. You can further tweak these behaviours by overriding functions on your classes. For example if each page on your website already contains a Hero Image, you may want to override `getDefaultOGImage()` to use this as the default image:

```
/**
 * Provide a better default OG image for pages
 */
public function getDefaultOGImage() {
	// Use hero image if available
	if ($this->HeroImageID) {
		return $this->HeroImage();
	}
	// Fallback to website's apple-touch-icon
	if (file_exists(BASE_PATH . '/apple-touch-icon.png')) {
		return Director::absoluteURL('apple-touch-icon.png', true);
	}
}
```

*Note that `og:image` is a [required property](http://ogp.me/), so please ensure that `getDefaultOGImage()` will always work. If your website includes an apple-touch-icon.png file in the root you'll be covered.*

#### Don't need that much control?

[](#dont-need-that-much-control)

As an alternative to the `ShareCareFields` extension, try taking the `ShareCareSingleSummary` extension for a spin. This opinionated extension lets CMS users choose a single image and a single summary to be used to represent a page within the website and on search engines and social media. It puts the fields front and centre above the main content field to encourage CMS users to actually fill them out. As a bonus it also hides that pesky 'custom meta tags' field away in the Settings tab.

[![Summary fields](screenshots/share-care-summary-fields.png)](screenshots/share-care-summary-fields.png)

Example configuration:

```
---
Name: mysharecare
After: "opengraphextensions"
---
Page:
  extensions:
    - JonoM\ShareCare\ShareCareSingleSummary
```

### Twitter integration

[](#twitter-integration)

Markup for a [large image summary](https://dev.twitter.com/cards/types/summary-large-image)Twitter card will be included if a large enough image is provided. To attribute content ownership set a Twitter username in your config.yml file. Example:

```
JonoM\ShareCare\ShareCare:
  twitter_username: "your-username"
```

Don't want Twitter card markup? Disable it like so:

```
JonoM\ShareCare\ShareCare:
  twitter: false
```

Note that Twitter will still use your open graph tags to produce a rich preview if this feature is disabled.

### Refresh Facebook's cache

[](#refresh-facebooks-cache)

Facebook caches open graph markup aggressively and may serve stale previews. To prevent this, you can automatically clear Facebook's cache after publishing or writing content.

You will probably need a Facebook access token for this functionality to work (it used to be optional but now seems to be required). See the [facebook access token docs entry](docs/en/facebook-access-token.md) for instructions on obtaining and using the token.

#### Opt in to Facebook cache clearing

[](#opt-in-to-facebook-cache-clearing)

You can opt in through the config system or object methods.

Use the following config to only attempt to purge the Facebook cache on live environments.

```
---
Only:
  environment:
    - live
---
JonoM\ShareCare\ShareCare:
  enable_facebook_cache_clear: true
```

If you need more control you can provide a `shouldClearFacebookCache()` method on your `Page` or `DataObject` class to return `true` or `false` as necessary. You may want to return the value of `Config::inst()->get('JonoM\ShareCare\ShareCare', 'enable_facebook_cache_clear')` as a fallback.

### Share links

[](#share-links)

You can use these methods in your templates to get a convenient share URL for each service

- `$FacebookShareLink`
- `$TwitterShareLink`
- `$PinterestShareLink`
- `$LinkedInShareLink`
- `$EmailShareLink`

#### Pinterest CMS integration

[](#pinterest-cms-integration)

If you're making use of the `ShareCareFields` extension and $PinterestShareLink, you can include a Pinterest preview in the CMS and allow CMS users to set a different image for Pinterest, as tall rather than wide images are better suited to this service.

```
JonoM\ShareCare\ShareCare:
  pinterest: true
```

Maintainer contact
------------------

[](#maintainer-contact)

[Jono Menz](https://jonomenz.com)

Please feel free to [get in touch](https://jonomenz.com) if you want to hire the maintainer to develop a new feature, or discuss another opportunity.

###  Health Score

57

—

FairBetter than 98% of packages

Maintenance80

Actively maintained with recent releases

Popularity39

Limited adoption so far

Community24

Small or concentrated contributor base

Maturity72

Established project with proven stability

 Bus Factor1

Top contributor holds 54.5% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~197 days

Recently: every ~88 days

Total

20

Last Release

94d ago

Major Versions

v1.2.2 → v2.0.02017-09-07

v2.0.0 → v3.0.02018-11-05

v3.0.2 → v4.0.02019-11-15

v4.2.4 → v5.0.02026-01-23

### Community

Maintainers

![](https://www.gravatar.com/avatar/54ba1a57c516be631e90bac916e1add4a84fe2b39284aa5a5cc5ea37c0d6cefa?d=identicon)[Jono M](/maintainers/Jono%20M)

---

Top Contributors

[![jonom](https://avatars.githubusercontent.com/u/1079425?v=4)](https://github.com/jonom "jonom (18 commits)")[![lerni](https://avatars.githubusercontent.com/u/472115?v=4)](https://github.com/lerni "lerni (3 commits)")[![RVXD](https://avatars.githubusercontent.com/u/1586761?v=4)](https://github.com/RVXD "RVXD (2 commits)")[![TheBnl](https://avatars.githubusercontent.com/u/1334195?v=4)](https://github.com/TheBnl "TheBnl (2 commits)")[![3Dgoo](https://avatars.githubusercontent.com/u/2616373?v=4)](https://github.com/3Dgoo "3Dgoo (1 commits)")[![purplespider](https://avatars.githubusercontent.com/u/329880?v=4)](https://github.com/purplespider "purplespider (1 commits)")[![sheadawson](https://avatars.githubusercontent.com/u/1166136?v=4)](https://github.com/sheadawson "sheadawson (1 commits)")[![sunnysideup](https://avatars.githubusercontent.com/u/167154?v=4)](https://github.com/sunnysideup "sunnysideup (1 commits)")[![phptek](https://avatars.githubusercontent.com/u/478440?v=4)](https://github.com/phptek "phptek (1 commits)")[![derralf](https://avatars.githubusercontent.com/u/1495867?v=4)](https://github.com/derralf "derralf (1 commits)")[![digitall-it](https://avatars.githubusercontent.com/u/3578378?v=4)](https://github.com/digitall-it "digitall-it (1 commits)")[![lozcalver](https://avatars.githubusercontent.com/u/1655548?v=4)](https://github.com/lozcalver "lozcalver (1 commits)")

---

Tags

facebooksilverstripesharesocial mediaopengraphopen-graph

### Embed Badge

![Health badge](/badges/jonom-silverstripe-share-care/health.svg)

```
[![Health](https://phpackages.com/badges/jonom-silverstripe-share-care/health.svg)](https://phpackages.com/packages/jonom-silverstripe-share-care)
```

###  Alternatives

[social-links/social-links

PHP library to generate share buttons

112338.6k2](/packages/social-links-social-links)[tractorcow/silverstripe-opengraph

Implementation of the Facebook Open Graph protocol for SilverStripe

52141.6k5](/packages/tractorcow-silverstripe-opengraph)[chriskonnertz/open-graph

Class that assists in building Open Graph meta tags

117428.6k3](/packages/chriskonnertz-open-graph)[silverstripe/environmentcheck

Provides an API for building environment tests

35503.8k13](/packages/silverstripe-environmentcheck)[symbiote/silverstripe-addressable

SilverStripe addressable and geocoding module

2985.1k7](/packages/symbiote-silverstripe-addressable)[umanskyi31/opengraph

Created a new component for Yii2. The Open Graph component for your website

119.7k](/packages/umanskyi31-opengraph)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
