You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This is not a duplicate of #51 and #52 - we checked this tickets and applied the suggested PR as well.
If you use ACF Gutenberg (create Gutenberg Blocks using ACF PHP API) there are two states:
Edit state: presenting the ACF edit form
Preview state: presenting the rendered content
In both states is_admin() is true, but in edit state ACF expects the return value to be the attachment id only, in contrast in preview state it should be the formatted value (e.g. array).
At the moment we did not yet find a way to check for edit-vs-preview in the plugin hook. But ACF will inject a variable $is_preview into the render template code. This is our only hint so far.
Maybe someone has smart approach for this?
The text was updated successfully, but these errors were encountered:
elmarbransch
changed the title
for ACF: does not return chosen format (e.g. array), but only the attachment post id
for ACF Gutenberg: does not return chosen format on preview (e.g. array), but only the attachment post id
Apr 17, 2020
While browsing the acf pro code we checked the handling of the $is_preview var and it looks like this can be derived in the same way inside our hook in this plugin.
if ( ! is_admin() ) {
...
}
else {
// code as seen in advanced-customfields-pro/pro/blocks.php::acf_ajax_fetch_block()
extract(acf_request_args(array('query'=>array())));
if( isset($query['preview']) && $query['preview'] == 'true' ) {
switch_to_media_site();
$image = $this->transform_acf_to_return_format( $field['return_format'], $value );
restore_current_blog();
}
}
Here is the relevant code portion for filter_acf_attachment_load_value()
Sorry for not providing a clean PR here ...
Best
Elmar
This is not a duplicate of #51 and #52 - we checked this tickets and applied the suggested PR as well.
If you use ACF Gutenberg (create Gutenberg Blocks using ACF PHP API) there are two states:
In both states is_admin() is true, but in edit state ACF expects the return value to be the attachment id only, in contrast in preview state it should be the formatted value (e.g. array).
At the moment we did not yet find a way to check for edit-vs-preview in the plugin hook. But ACF will inject a variable $is_preview into the render template code. This is our only hint so far.
Maybe someone has smart approach for this?
The text was updated successfully, but these errors were encountered: