Enhancement: Custom “layout graphic”
-
I use FPW almost exclusively (thanks again) and often have custom layouts. It would be nice to allow the customization of
layoutIcons.svg
, though I don’t know if this rarely used feature would be worth the code to implement it.How I might go about it:
Graphic(s)
Allow SVG or PNG files within
fpw2_views
whose filename matches the template file name except for the extension.Display Option 1: via CSS
Untested!
function fpw_layout_css( ) { $templates = fpw_widget_templates(); $css = ''; $exts = [ 'svg', 'png' ]; foreach( $templates as $key => $title ) { $file = $url = ''; $path = '/fpw2_views/' . $key . '.'; foreach( $exts as $ext ) { $try = get_stylesheet_directory() . $path . $ext; if ( file_exists( $try) ) { $file = $try; $url = get_stylesheet_directory_uri() . $path . $ext; break; } } if ( ! $file ) continue; $css .= '.fpw-layouts .fpw-layout-' . $key . ':checked + label::after{'; $css .= 'background-image: url( ' . $url . ');'; $css .= 'background-position: 0 0;'; $css .= '}'; } if ( $css ) { wp_add_inline_style( 'fpw_admin_css', $css ); } }
Display Option 2: Use JS
Not going to code it, but would involve watching the click on the layout options, checking if the BG position of the label is 0,0, and then using ajax to try and get a new BG graphic. I think.
Anyway, this would add a nice polishing touch to custom layouts. And, actually, now that I’m asking for the moon, it would be nice if the standard graphic could be replaced by having an exact-named graphic in the
fpw2_views
directory. I often co-opt standard layouts to reverse title/image order or similar. This is much less of a priority.If you use github for source control, would be happy to do a pull request there.
- The topic ‘Enhancement: Custom “layout graphic”’ is closed to new replies.