-
-
Save courtneymyers/eb51f918181746181871f7ae516b428b to your computer and use it in GitHub Desktop.
<?php | |
/* | |
* ----------------------------------------------------------------------------- | |
* Advanced Custom Fields Modifications | |
* ----------------------------------------------------------------------------- | |
*/ | |
function PREFIX_apply_acf_modifications() { | |
?> | |
<style> | |
.acf-editor-wrap iframe { | |
min-height: 0; | |
} | |
</style> | |
<script> | |
(function($) { | |
// (filter called before the tinyMCE instance is created) | |
acf.add_filter('wysiwyg_tinymce_settings', function(mceInit, id, $field) { | |
// enable autoresizing of the WYSIWYG editor | |
mceInit.wp_autoresize_on = true; | |
return mceInit; | |
}); | |
// (action called when a WYSIWYG tinymce element has been initialized) | |
acf.add_action('wysiwyg_tinymce_init', function(ed, id, mceInit, $field) { | |
// reduce tinymce's min-height settings | |
ed.settings.autoresize_min_height = 100; | |
// reduce iframe's 'height' style to match tinymce settings | |
$('.acf-editor-wrap iframe').css('height', '100px'); | |
}); | |
})(jQuery) | |
</script> | |
<?php | |
} | |
/* | |
* ----------------------------------------------------------------------------- | |
* WordPress hooks | |
* ----------------------------------------------------------------------------- | |
*/ | |
add_action('acf/input/admin_footer', 'PREFIX_apply_acf_modifications'); |
Very very cool, thanks a lot!
Works great! Thanks!
Thanks! This is working great in a repeater that was way too tall before.
Working great here too, Thanks!
Should be a parameter for this in ACF admin...
Awesome, much appreciated!
Since I make heavy use of the 'delay'-option ("Defers initialization of editor until editor is clicked instead of on page load. This is useful to speed up load times") I added a line that targets the initial Textarea accrodingly – the small height is compensated by a vertical scroll and on init the TinyMCE-box automatically resizes so no downsides there IMHO...
This is my modified Script:
<?php
/*
* -----------------------------------------------------------------------------
* Advanced Custom Fields Modifications
* -----------------------------------------------------------------------------
*/
function PREFIX_apply_acf_modifications() {
?>
<style>
.acf-editor-wrap iframe {
min-height: 0;
}
</style>
<script>
(function($) {
// reduce placeholder textarea height to match tinymce settings (when using delay-setting)
$('.acf-editor-wrap.delay textarea').css('height', '100px');
// (filter called before the tinyMCE instance is created)
acf.add_filter('wysiwyg_tinymce_settings', function(mceInit, id, $field) {
// enable autoresizing of the WYSIWYG editor
mceInit.wp_autoresize_on = true;
return mceInit;
});
// (action called when a WYSIWYG tinymce element has been initialized)
acf.add_action('wysiwyg_tinymce_init', function(ed, id, mceInit, $field) {
// reduce tinymce's min-height settings
ed.settings.autoresize_min_height = 100;
// reduce iframe's 'height' style to match tinymce settings
$('.acf-editor-wrap iframe').css('height', '100px');
});
})(jQuery)
</script>
<?php
}
/*
* -----------------------------------------------------------------------------
* WordPress hooks
* -----------------------------------------------------------------------------
*/
add_action('acf/input/admin_footer', 'PREFIX_apply_acf_modifications');
I know this post is old, so I'm not sure if anyone would respond.
I added the last script from E-Vance, but when I create multiple fields from an ACF repeater field, the previous field shrinks and doesn't expand when clicked.
Is there a way to fix this?
ACF JavaScript reference