PHPackages                             mosaicora/module-opengraph - 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. [API Development](/categories/api)
4. /
5. mosaicora/module-opengraph

ActiveMagento2-module[API Development](/categories/api)

mosaicora/module-opengraph
==========================

Open Graph and Twitter Card metadata module for Magento 2, Mage-OS, and Adobe Commerce, with image optimization, REST, and GraphQL APIs

1.0.3(1mo ago)123GPL-3.0-or-laterPHPPHP ~8.1.0||~8.2.0||~8.3.0||~8.4.0||~8.5.0CI passing

Since Jun 5Pushed 1mo ago1 watchersCompare

[ Source](https://github.com/Mosaicora/module-opengraph)[ Packagist](https://packagist.org/packages/mosaicora/module-opengraph)[ Docs](https://github.com/Mosaicora/module-opengraph)[ RSS](/packages/mosaicora-module-opengraph/feed)WikiDiscussions master Synced 1w ago

READMEChangelog (4)Dependencies (34)Versions (5)Used By (0)

Mosaicora Open Graph
====================

[](#mosaicora-open-graph)

Open Graph and Twitter Card metadata module for Magento 2, Mage-OS, and Adobe Commerce storefronts.

`mosaicora/module-opengraph` gives product, category, CMS, and home pages the metadata that social platforms need to generate clean share previews. It works out of the box with sensible defaults, while still giving store teams per-store control over titles, descriptions, images, and generated social-preview image sizes.

Live Demo
---------

[](#live-demo)

A Magento demo shop configured with this module is available at .

Use the free Mosaicora Open Graph Checker at  to inspect the shop's Open Graph tags and preview how its pages will appear when shared. Try these ready-made examples:

- [Preview the Bags category](https://mosaicora.io/tools/open-graph-checker?url=https%3A%2F%2Fdemo-shop-magento.mosaicora.io%2Fgear%2Fbags.html)
- [Preview the Joust Duffle Bag](https://mosaicora.io/tools/open-graph-checker?url=https%3A%2F%2Fdemo-shop-magento.mosaicora.io%2Fjoust-duffle-bag.html)
- [Preview the Voyage Yoga Bag](https://mosaicora.io/tools/open-graph-checker?url=https%3A%2F%2Fdemo-shop-magento.mosaicora.io%2Fvoyage-yoga-bag.html)

Why Use It
----------

[](#why-use-it)

- Adds Open Graph metadata across common storefront page types.
- Mirrors Open Graph values into optional Twitter Card tags.
- Lets admins choose title, description, and image sources without template changes.
- Supports custom Open Graph images for categories and CMS pages.
- Generates cached `1200x630` social-preview images from local Magento media assets by default.
- Provides an admin cache action for flushing generated Open Graph images.

Supported Pages
---------------

[](#supported-pages)

The module resolves the active storefront context and applies metadata during layout generation.

- Product pages use the current product.
- Category pages use the current category on `catalog_category_view`.
- CMS pages use the active CMS page captured during render.
- The home page uses the current CMS home page when available, otherwise it falls back to the configured site name and default image.

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

[](#requirements)

- PHP `~8.1` to `~8.5`
- Magento 2, Mage-OS, or Adobe Commerce with the Catalog, CMS, Store, Web API, and GraphQL modules enabled.
- Composer credentials for `repo.magento.com` when installing Magento packages directly.

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

[](#installation)

Install the package through Composer:

```
composer require mosaicora/module-opengraph
```

Run the normal Magento upgrade and cache workflow:

```
bin/magento module:enable Mosaicora_OpenGraph
bin/magento setup:upgrade
bin/magento cache:flush config layout block_html eav full_page config_webservice
```

For production-mode deployments, also regenerate dependency injection and static content according to the store's deployment process:

```
bin/magento setup:di:compile
bin/magento setup:static-content:deploy
```

Install dependencies from the Magento project root. Do not run `composer install` inside a module directory mounted or symlinked into Magento because a nested `vendor/` tree causes duplicate class loading during compilation.

Configuration
-------------

[](#configuration)

The module adds a configuration section at:

`Stores > Configuration > Mosaicora > Open Graph`

Configuration is store-scoped where Magento allows it, so each store view can use its own site name, default image, metadata source attributes, and image optimization settings.

### General

[](#general)

- `Enable Open Graph Tags`
- `Site Name`
- `Default Image`
- `Enable Twitter Card Tags`
- `Twitter Card Type`
- `Remove Competing Social Tags`

`Remove Competing Social Tags` is disabled by default. When enabled, Mosaicora removes duplicate Open Graph, product, and enabled Twitter Card tags for metadata keys that this module generates, so Mosaicora's values win.

### Image Optimization

[](#image-optimization)

- `Serve Optimized OG Image`
- `Width`
- `Height`
- `Resize Mode`
- `Background Color`

Image optimization is enabled by default and uses `1200x630`, the common Open Graph share-card aspect ratio. Local Magento media images can be converted into cached social-preview images. External image URLs are left unchanged.

### Content Defaults

[](#content-defaults)

- Product title, description, and image attribute sources.
- Category title and description attribute sources.
- CMS title and description field sources.

Individual products, categories, and CMS pages can also provide Open Graph-specific values when the module attributes or fields are available.

Metadata Output
---------------

[](#metadata-output)

The module can output:

- `og:type`
- `og:url`
- `og:site_name`
- `og:title`
- `og:description`
- `og:image`
- `og:image:width`
- `og:image:height`
- `twitter:card`
- `twitter:title`
- `twitter:description`
- `twitter:image`

Product pages may also output:

- `product:price:amount`
- `product:price:currency`
- `product:availability` with `instock` or `oos`

Twitter tags are copied from the resolved Open Graph values when Twitter Card output is enabled.

### Duplicate Social Tags

[](#duplicate-social-tags)

Magento, themes, and third-party extensions may emit their own Open Graph or Twitter Card tags. The preferred setup is to disable that output in the other module or theme so only one metadata provider remains active.

If the competing output cannot be disabled, enable `Remove Competing Social Tags` under `Stores > Configuration > Mosaicora > Open Graph > General`. The switch is off by default for compatibility. When enabled, it removes competing tags only for metadata keys generated by Mosaicora and keeps unrelated tags.

Metadata API
------------

[](#metadata-api)

The module exposes anonymous read-only metadata endpoints intended for preview tooling and integrations:

- `GET /V1/mosaicora/opengraph/product/:sku`
- `GET /V1/mosaicora/opengraph/category/:categoryId`
- `GET /V1/mosaicora/opengraph/cms/:identifier`
- `GET /V1/mosaicora/opengraph/home`

These endpoints return the same resolved tags that frontend pages use. They do not expose private catalog data, but they are intentionally public.

Send Magento's standard `Store` request header to resolve metadata for a specific store view.

### GraphQL

[](#graphql)

GraphQL exposes the same metadata on Magento's native storefront types:

- `ProductInterface.open_graph`
- `CategoryInterface.open_graph`
- `CmsPage.open_graph`
- `StoreConfig.home_open_graph`

The `tags` field uses the same flexible `name` and `content` list returned by REST, including Open Graph, Twitter Card, and product metadata.

```
query ProductOpenGraph($sku: String!) {
  products(filter: { sku: { eq: $sku } }) {
    items {
      sku
      open_graph {
        page_type
        identifier
        store_id
        enabled
        tags {
          name
          content
        }
      }
    }
  }
}
```

```
query CategoryOpenGraph($uid: String!) {
  categories(filters: { category_uid: { eq: $uid } }) {
    items {
      uid
      open_graph {
        enabled
        tags {
          name
          content
        }
      }
    }
  }
}
```

```
query PageOpenGraph($identifier: String!) {
  cmsPage(identifier: $identifier) {
    identifier
    open_graph {
      enabled
      tags {
        name
        content
      }
    }
  }

  storeConfig {
    home_open_graph {
      enabled
      tags {
        name
        content
      }
    }
  }
}
```

Disabled configuration returns `enabled: false` and an empty `tags` list. REST and GraphQL use the same normalized tag builders and storefront canonical URLs.

Default Resolution
------------------

[](#default-resolution)

Out of the box, the module uses these fallbacks:

- Product title: `meta_title`, then `name`
- Product description: `meta_description`, then `short_description`, then `description`
- Product image: `open_graph_image`, then `image`, then `small_image`
- Category title: `meta_title`, then `name`
- Category description: `meta_description`, then `description`
- Category image: `image`
- CMS title: `meta_title`, then `title`
- CMS description: `meta_description`, then `content`
- Home page title: configured site name
- Home page image: configured default image

Text values are sanitized before output and truncated when needed.

Images
------

[](#images)

Product images are resolved from the configured product image attribute and then through the default fallback list until a usable image is found.

Category images can use the category image automatically or a custom `og_image_custom` category attribute.

CMS pages can use the configured default image or a custom uploaded image stored in `og_image_custom`.

Only normalized paths under Magento media are used for local image optimization. Remote URLs are emitted unchanged and are never used for filesystem reads or generated cache files.

When image optimization is enabled, generated images are cached in:

`pub/media/mosaicora/opengraph/cache`

The cache key accounts for the source file, source modification time, target dimensions, and resize mode. Authorized admin users can clear generated Open Graph images from the Magento cache management screen.

Admin Fields
------------

[](#admin-fields)

The installation patches add these product attributes:

- `open_graph_image`
- `og_title_mode`
- `og_title_attribute`
- `og_title_custom`
- `og_description_mode`
- `og_description_attribute`
- `og_description_custom`

The installation patches add these category attributes:

- `og_title_mode`
- `og_title_attribute`
- `og_title_custom`
- `og_description_mode`
- `og_description_attribute`
- `og_description_custom`
- `og_image_mode`
- `og_image_custom`

CMS pages receive matching Open Graph fields through the admin UI component.

Admin Permissions
-----------------

[](#admin-permissions)

The module adds permissions for configuration access and generated image cache management:

- `Mosaicora_OpenGraph::config`
- `Mosaicora_OpenGraph::flush_open_graph_images`

Development
-----------

[](#development)

When the module is mounted in Magento, run checks with the parent dependency tree:

```
vendor/bin/phpcs --standard=[module path]/Mosaicora_OpenGraph/phpcs.xml [module path]/Mosaicora_OpenGraph
vendor/bin/phpunit --configuration [module path]/Mosaicora_OpenGraph/phpunit.xml.dist
```

For a standalone clone outside Magento, configure `auth.json` for `repo.magento.com`, run `composer install`, then use `composer phpcs` and `composer test`.

CI validates the package on PHP 8.1 and PHP 8.5. Pull requests from forks do not receive Magento repository credentials; maintainers rerun reviewed changes from a trusted repository branch.

Project Links
-------------

[](#project-links)

- [Contributing](./CONTRIBUTING.md)
- [Security](./SECURITY.md)
- [Changelog](./CHANGELOG.md)
- [License](./LICENSE)

License
-------

[](#license)

GPL-3.0-or-later

Maintainer
----------

[](#maintainer)

Built and maintained by [Mosaicora.io](https://mosaicora.io).

Mosaicora automatically creates stunning Open Graph images from your web pages using beautiful, customizable templates. No design tools or uploads needed.

###  Health Score

43

—

FairBetter than 89% of packages

Maintenance93

Actively maintained with recent releases

Popularity8

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity54

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% 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 ~2 days

Total

4

Last Release

42d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/00ce1327e21803e4977bc625ae3f0db7f4d027e0f19c367cc30f3365da4ce5b5?d=identicon)[datanasov](/maintainers/datanasov)

---

Top Contributors

[![drashmk](https://avatars.githubusercontent.com/u/2790702?v=4)](https://github.com/drashmk "drashmk (7 commits)")

---

Tags

adobe-commercehyvamage-osmagento-2-extensionmagento-2-modulesmagento-modulemagento2magento2-moduleopen-graphopen-graph-generatoropengraphseographqlmagentomagento2open-graphtwitter cardsadobe commercemage-ossocial metadata

###  Code Quality

TestsPHPUnit

Code StylePHP\_CodeSniffer

### Embed Badge

![Health badge](/badges/mosaicora-module-opengraph/health.svg)

```
[![Health](https://phpackages.com/badges/mosaicora-module-opengraph/health.svg)](https://phpackages.com/packages/mosaicora-module-opengraph)
```

###  Alternatives

[mollie/magento2

Mollie Payment Module for Magento 2

1131.9M16](/packages/mollie-magento2)[smile/elasticsuite

Magento 2 merchandising and search engine built on ElasticSearch

8064.7M50](/packages/smile-elasticsuite)[run-as-root/magento2-prometheus-exporter

Magento2 Prometheus Exporter

68357.9k](/packages/run-as-root-magento2-prometheus-exporter)[opengento/module-category-import-export

This module add the capability to import and export the categories from the back-office.

1310.9k2](/packages/opengento-module-category-import-export)[buckaroo/magento2

Buckaroo Magento 2 extension

32420.3k8](/packages/buckaroo-magento2)[loki/magento2-components

Core module for defining Alpine.js components with advanced AJAX features

1011.8k26](/packages/loki-magento2-components)

PHPackages © 2026

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