As of Embedded Assets 2.4.0, Embedded Assets supports the GraphQL functionality provided by Craft CMS Pro. Embedded asset data can be retrieved by accessing an embeddedAsset
property on a Craft asset field. A basic example follows, in which an embedded asset's title is retrieved:
query {
entry(slug: "homepage") {
... on homepage_homepage_Entry {
embeddedAssetField {
embeddedAsset {
title
}
}
}
}
}
If the asset field contains any assets that are not embedded assets, embeddedAsset
will just return null
for those assets.
All properties of an embedded asset listed on the Templating page can be retrieved from an embeddedAsset
, as well as the following:
isSafe
- checks an embedded asset embed code for URLs that are safe. See the documentation for theEmbeddedAsset
model'sgetIsSafe()
method for more details.iframeSrc
- if the embedded asset'scode
is an<iframe>
, returns the<iframe>
'ssrc
attribute with extra parameters added. Requires theparams
argument, passed in the same format as theEmbeddedAsset
model'sgetIframeSrc()
method.iframeCode
- if the embedded asset'scode
is an<iframe>
, returns the<iframe>
with extra parameters added to thesrc
attribute, or extra attributes added to the<iframe>
element. Requires theparams
argument and also accepts theattributes
argument, passed in the same format as theEmbeddedAsset
model'sgetIframeCode()
method.