changing block to auto-pull page cover illustration instead of icon
This commit is contained in:
parent
99b5273e5e
commit
66c950530b
|
|
@ -1 +1 @@
|
||||||
<?php return array('dependencies' => array('wp-block-editor', 'wp-blocks', 'wp-components', 'wp-data', 'wp-element', 'wp-i18n', 'wp-primitives'), 'version' => '55aaaaa96d363ec8c816');
|
<?php return array('dependencies' => array('wp-block-editor', 'wp-blocks', 'wp-components', 'wp-data', 'wp-element', 'wp-i18n', 'wp-primitives'), 'version' => '9816905fa59c35015482');
|
||||||
|
|
|
||||||
|
|
@ -54,13 +54,14 @@ function Edit({
|
||||||
} = select("core/editor");
|
} = select("core/editor");
|
||||||
return getEditedPostAttribute("title");
|
return getEditedPostAttribute("title");
|
||||||
});
|
});
|
||||||
const pageIcon = (0,_wordpress_data__WEBPACK_IMPORTED_MODULE_3__.useSelect)(select => {
|
const pageIllustration = (0,_wordpress_data__WEBPACK_IMPORTED_MODULE_3__.useSelect)(select => {
|
||||||
const currentPost = select("core/editor").getCurrentPost();
|
const currentPost = select("core/editor").getCurrentPost();
|
||||||
if (currentPost && currentPost.acf && currentPost.acf.page_icon) {
|
if (currentPost && currentPost.acf && currentPost.acf.page_illustration) {
|
||||||
let Image = select("core").getMedia(currentPost.acf.page_icon);
|
let Image = select("core").getMedia(currentPost.acf.page_illustration);
|
||||||
return Image;
|
return Image;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
console.log("pageIllustration", pageIllustration);
|
||||||
function onChangeBlockCustomTitle(blockCustomTitle) {
|
function onChangeBlockCustomTitle(blockCustomTitle) {
|
||||||
setAttributes({
|
setAttributes({
|
||||||
blockCustomTitle
|
blockCustomTitle
|
||||||
|
|
@ -152,7 +153,7 @@ function Edit({
|
||||||
label: "Couverture automatique",
|
label: "Couverture automatique",
|
||||||
checked: !hasCustomImage,
|
checked: !hasCustomImage,
|
||||||
onChange: onChangeHasCustomImage
|
onChange: onChangeHasCustomImage
|
||||||
}), !hasCustomImage && (0,_wordpress_element__WEBPACK_IMPORTED_MODULE_0__.createElement)(_wordpress_components__WEBPACK_IMPORTED_MODULE_5__.Tip, null, "La couverture est automatiquement g\xE9n\xE9r\xE9 \xE0 partir de l'icone de la page"), hasCustomImage && (0,_wordpress_element__WEBPACK_IMPORTED_MODULE_0__.createElement)(_wordpress_element__WEBPACK_IMPORTED_MODULE_0__.Fragment, null, imageUrl && (0,_wordpress_element__WEBPACK_IMPORTED_MODULE_0__.createElement)("img", {
|
}), !hasCustomImage && (0,_wordpress_element__WEBPACK_IMPORTED_MODULE_0__.createElement)(_wordpress_components__WEBPACK_IMPORTED_MODULE_5__.Tip, null, "La couverture est automatiquement g\xE9n\xE9r\xE9 \xE0 partir de l'illustration de couverture de la page."), hasCustomImage && (0,_wordpress_element__WEBPACK_IMPORTED_MODULE_0__.createElement)(_wordpress_element__WEBPACK_IMPORTED_MODULE_0__.Fragment, null, imageUrl && (0,_wordpress_element__WEBPACK_IMPORTED_MODULE_0__.createElement)("img", {
|
||||||
src: imageUrl,
|
src: imageUrl,
|
||||||
alt: imageAlt
|
alt: imageAlt
|
||||||
}), (0,_wordpress_element__WEBPACK_IMPORTED_MODULE_0__.createElement)("div", {
|
}), (0,_wordpress_element__WEBPACK_IMPORTED_MODULE_0__.createElement)("div", {
|
||||||
|
|
@ -222,9 +223,9 @@ function Edit({
|
||||||
allowedBlocks: ["core/paragraph", "core/list", "core/button", "core/buttons", "gravityforms/form", "homegrade-content-blocks/section-titling"]
|
allowedBlocks: ["core/paragraph", "core/list", "core/button", "core/buttons", "gravityforms/form", "homegrade-content-blocks/section-titling"]
|
||||||
}), cta && cta.title && cta.url && (0,_wordpress_element__WEBPACK_IMPORTED_MODULE_0__.createElement)("a", {
|
}), cta && cta.title && cta.url && (0,_wordpress_element__WEBPACK_IMPORTED_MODULE_0__.createElement)("a", {
|
||||||
href: cta.url
|
href: cta.url
|
||||||
}, cta.title)), pageIcon && !hasCustomImage && (0,_wordpress_element__WEBPACK_IMPORTED_MODULE_0__.createElement)("img", {
|
}, cta.title)), pageIllustration && !hasCustomImage && (0,_wordpress_element__WEBPACK_IMPORTED_MODULE_0__.createElement)("img", {
|
||||||
className: "block-content-page-header__page-icon",
|
className: "block-content-page-header__page-icon",
|
||||||
src: pageIcon.source_url,
|
src: pageIllustration.source_url,
|
||||||
alt: ""
|
alt: ""
|
||||||
}), hasCustomImage && imageUrl && (0,_wordpress_element__WEBPACK_IMPORTED_MODULE_0__.createElement)("img", {
|
}), hasCustomImage && imageUrl && (0,_wordpress_element__WEBPACK_IMPORTED_MODULE_0__.createElement)("img", {
|
||||||
src: imageUrl,
|
src: imageUrl,
|
||||||
|
|
|
||||||
File diff suppressed because one or more lines are too long
|
|
@ -2,7 +2,7 @@
|
||||||
$pageHeaderTitle = $attributes['pageHeaderTitle'] ?? null;
|
$pageHeaderTitle = $attributes['pageHeaderTitle'] ?? null;
|
||||||
$pageHeaderDescription = $attributes['pageHeaderDescription'] ?? null;
|
$pageHeaderDescription = $attributes['pageHeaderDescription'] ?? null;
|
||||||
$cta = $attributes['cta'] ?? null;
|
$cta = $attributes['cta'] ?? null;
|
||||||
$pageIcon = get_field('page_icon');
|
$pageIllustration = get_field('page_illustration');
|
||||||
|
|
||||||
$hasCustomImage = $attributes['hasCustomImage'] ?? null;
|
$hasCustomImage = $attributes['hasCustomImage'] ?? null;
|
||||||
$customImageUrl = $attributes['imageUrl'] ?? null;
|
$customImageUrl = $attributes['imageUrl'] ?? null;
|
||||||
|
|
@ -31,8 +31,8 @@ $customTitle = $attributes['blockCustomTitle'] ?? null;
|
||||||
<?php endif; ?>
|
<?php endif; ?>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<?php if ($pageIcon && !$hasCustomImage) : ?>
|
<?php if ($pageIllustration && !$hasCustomImage) : ?>
|
||||||
<img class="block-content-page-header__page-icon" src="<?php echo $pageIcon['url'] ?>" alt="">
|
<img class="block-content-page-header__page-icon" src="<?php echo $pageIllustration['url'] ?>" alt="">
|
||||||
<?php endif; ?>
|
<?php endif; ?>
|
||||||
<?php if ($hasCustomImage && $customImageUrl) : ?>
|
<?php if ($hasCustomImage && $customImageUrl) : ?>
|
||||||
<img class="block-content-page-header__page-icon" src="<?php echo $customImageUrl ?>" alt="<?php echo $customImageAlt ?>">
|
<img class="block-content-page-header__page-icon" src="<?php echo $customImageUrl ?>" alt="<?php echo $customImageAlt ?>">
|
||||||
|
|
|
||||||
|
|
@ -41,14 +41,16 @@ export default function Edit({ attributes, setAttributes }) {
|
||||||
return getEditedPostAttribute("title");
|
return getEditedPostAttribute("title");
|
||||||
});
|
});
|
||||||
|
|
||||||
const pageIcon = useSelect((select) => {
|
const pageIllustration = useSelect((select) => {
|
||||||
const currentPost = select("core/editor").getCurrentPost();
|
const currentPost = select("core/editor").getCurrentPost();
|
||||||
if (currentPost && currentPost.acf && currentPost.acf.page_icon) {
|
if (currentPost && currentPost.acf && currentPost.acf.page_illustration) {
|
||||||
let Image = select("core").getMedia(currentPost.acf.page_icon);
|
let Image = select("core").getMedia(currentPost.acf.page_illustration);
|
||||||
return Image;
|
return Image;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
console.log("pageIllustration", pageIllustration);
|
||||||
|
|
||||||
function onChangeBlockCustomTitle(blockCustomTitle) {
|
function onChangeBlockCustomTitle(blockCustomTitle) {
|
||||||
setAttributes({ blockCustomTitle });
|
setAttributes({ blockCustomTitle });
|
||||||
}
|
}
|
||||||
|
|
@ -139,8 +141,8 @@ export default function Edit({ attributes, setAttributes }) {
|
||||||
/>
|
/>
|
||||||
{!hasCustomImage && (
|
{!hasCustomImage && (
|
||||||
<Tip>
|
<Tip>
|
||||||
La couverture est automatiquement généré à partir de l'icone de la
|
La couverture est automatiquement généré à partir de
|
||||||
page
|
l'illustration de couverture de la page.
|
||||||
</Tip>
|
</Tip>
|
||||||
)}
|
)}
|
||||||
{hasCustomImage && (
|
{hasCustomImage && (
|
||||||
|
|
@ -265,10 +267,10 @@ export default function Edit({ attributes, setAttributes }) {
|
||||||
/>
|
/>
|
||||||
{cta && cta.title && cta.url && <a href={cta.url}>{cta.title}</a>}
|
{cta && cta.title && cta.url && <a href={cta.url}>{cta.title}</a>}
|
||||||
</div>
|
</div>
|
||||||
{pageIcon && !hasCustomImage && (
|
{pageIllustration && !hasCustomImage && (
|
||||||
<img
|
<img
|
||||||
className="block-content-page-header__page-icon"
|
className="block-content-page-header__page-icon"
|
||||||
src={pageIcon.source_url}
|
src={pageIllustration.source_url}
|
||||||
alt=""
|
alt=""
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@
|
||||||
$pageHeaderTitle = $attributes['pageHeaderTitle'] ?? null;
|
$pageHeaderTitle = $attributes['pageHeaderTitle'] ?? null;
|
||||||
$pageHeaderDescription = $attributes['pageHeaderDescription'] ?? null;
|
$pageHeaderDescription = $attributes['pageHeaderDescription'] ?? null;
|
||||||
$cta = $attributes['cta'] ?? null;
|
$cta = $attributes['cta'] ?? null;
|
||||||
$pageIcon = get_field('page_icon');
|
$pageIllustration = get_field('page_illustration');
|
||||||
|
|
||||||
$hasCustomImage = $attributes['hasCustomImage'] ?? null;
|
$hasCustomImage = $attributes['hasCustomImage'] ?? null;
|
||||||
$customImageUrl = $attributes['imageUrl'] ?? null;
|
$customImageUrl = $attributes['imageUrl'] ?? null;
|
||||||
|
|
@ -31,8 +31,8 @@ $customTitle = $attributes['blockCustomTitle'] ?? null;
|
||||||
<?php endif; ?>
|
<?php endif; ?>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<?php if ($pageIcon && !$hasCustomImage) : ?>
|
<?php if ($pageIllustration && !$hasCustomImage) : ?>
|
||||||
<img class="block-content-page-header__page-icon" src="<?php echo $pageIcon['url'] ?>" alt="">
|
<img class="block-content-page-header__page-icon" src="<?php echo $pageIllustration['url'] ?>" alt="">
|
||||||
<?php endif; ?>
|
<?php endif; ?>
|
||||||
<?php if ($hasCustomImage && $customImageUrl) : ?>
|
<?php if ($hasCustomImage && $customImageUrl) : ?>
|
||||||
<img class="block-content-page-header__page-icon" src="<?php echo $customImageUrl ?>" alt="<?php echo $customImageAlt ?>">
|
<img class="block-content-page-header__page-icon" src="<?php echo $customImageUrl ?>" alt="<?php echo $customImageAlt ?>">
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user