Steve
Forum Replies Created
-
Forum: Fixing WordPress
In reply to: Unable to create zip file for gutenberg blockOK I’ve got it.
I renamed the following field in ‘package.json’ to match the project name.
“name”: “team-members”,Then renamed the main php file to ‘team-members.php’
All working now.
Thank you so much for your help, it made me think in the right way.
Steve
Forum: Fixing WordPress
In reply to: Unable to create zip file for gutenberg blockOK thank you Threadi, will take a look.
Steve.
Forum: Fixing WordPress
In reply to: Unable to create zip file for gutenberg blockIn the zip, I can click “.” and that takes me to two files:
block.json
readme.txtSo at the top level its as if there are two directories named as follows:
.
buildSteve
- This reply was modified 4 years ago by Steve.
Forum: Fixing WordPress
In reply to: Unable to create zip file for gutenberg blockHi Threadi,
Thank you for your reply.
I have the following files in the zip:
index.asset.php index.css index.css.map index.js index.js.map style-index.css style-index.css.mapBut they are in the build directory within the zip.
I can zip them up manually of course but is it possible to get plugin-zip to put the files at the top level?
There were no file at the top level by the way.
Steve.
Forum: Fixing WordPress
In reply to: Unable to create zip file for gutenberg blockHello,
I finally got the plugin-zip working, it turns out that I had an out of date @wordpress/scripts installed.
So I was able to create a zip file but unfortunately when I tried to install it it failed, messages are as follows:
Unpacking the package…
Installing the plugin…
The package could not be installed. No valid plugins were found.
Plugin installation failed.
Go to Plugin InstallerAnyone got any ideas?
Steve
Forum: Fixing WordPress
In reply to: Unable to create zip file for gutenberg blockHello Threadi,
Thank you for your reply.
I have this line in my package.json:
“@wordpress/scripts”: “^19.2.2”,
I assume that means @wordpress/scripts installed.
Is it worth reinstalling? Do I need to update it perhaps?I put the full package.json below.
Best Regards,
Steve
{ "name": "boilerplate", "version": "0.1.0", "description": "Example block written with ESNext standard and JSX support – build step required.", "author": "", "license": "GPL-2.0-or-later", "main": "build/index.js", "scripts": { "build": "wp-scripts build", "format": "wp-scripts format && stylelint \"**/*.scss\" --fix", "lint:css": "wp-scripts lint-style", "lint:js": "wp-scripts lint-js", "start": "wp-scripts start", "packages-update": "wp-scripts packages-update", "prepare": "husky install", "plugin-zip": "wp-scripts plugin-zip" }, "prettier": "@wordpress/prettier-config", "stylelint": { "extends": "@wordpress/stylelint-config/scss" }, "lint-staged": { "*.js": [ "wp-scripts lint-js", "wp-scripts format" ], "*.scss": "npx stylelint --fix" }, "dependencies": { "@wordpress/blob": "^3.6.0", "@wordpress/block-editor": "^8.0.11", "@wordpress/blocks": "^11.1.4", "@wordpress/components": "^19.7.0", "@wordpress/compose": "^5.4.0", "@wordpress/data": "^6.6.0", "@wordpress/element": "^4.4.0", "@wordpress/i18n": "^4.2.4" }, "devDependencies": { "@wordpress/eslint-plugin": "^9.3.0", "@wordpress/prettier-config": "^1.1.1", "@wordpress/scripts": "^19.2.2", "@wordpress/stylelint-config": "^19.1.0", "eslint-config-prettier": "^8.3.0", "husky": "^7.0.4", "lint-staged": "^12.1.3" } }Forum: Developing with WordPress
In reply to: How to Access Custom Images from a Gutenberg block?Hi,
To answer my own question, I discovered that I can access the image url from the image parameter, i.e.
function onSelectImage(newImage) {
console.log(newImage.sizes.medium.url);
}I still couldn’t access my custom sized image, I found that it needs to be added using image_size_names_choose filter, there’s an explanation of how to do this here:
https://javascriptforwp.com/forums/topic/getting-specific-image-size-from-mediaupload-component/Best Regards,
Steve
- This reply was modified 5 years, 3 months ago by Steve.
Forum: Everything else WordPress
In reply to: Cropping generated images manually to a fixed aspect ratioHi,
To answer my own question, I discovered that I can access the image url from the image parameter, i.e.
function onSelectImage(newImage) {
console.log(newImage.sizes.medium.url);
}I still couldn’t access my custom sized image, I found that it needs to be added using image_size_names_choose filter, there’s an explanation of how to do this here:
https://javascriptforwp.com/forums/topic/getting-specific-image-size-from-mediaupload-component/Best Regards,
Steve
Forum: Everything else WordPress
In reply to: Cropping generated images manually to a fixed aspect ratioHi,
So I found a plugin which allows me upload an image and then crop separate images each with their own aspect ratio:
https://wordpress.org/plugins/crop-thumbnails/It was very easy to use and the documentation even has some sample code which worked without issue.
Now I have to work out how to access the cropped images via a Gutenberg block, I will post that here when I discover how to do it.
Steve
- This reply was modified 5 years, 3 months ago by Steve.
Forum: Everything else WordPress
In reply to: Cropping generated images manually to a fixed aspect ratioHi Tony,
Thank you for your reply and suggestion.
I was hoping for a plugin that I can just configure as that would be a lot less work.
I’m assuming that this is a pretty common requirement so I don’t want to reinvent the wheel.Best Regards,
Steve
Forum: Plugins
In reply to: [CMB2] Unable to display image urlHi Michael,
Finally, I got it working 🙂 Your hint on looking at the full array meant I found the image id, once I had that it was just a matter of googling to find out how to retrieve the urls.
$FullArray = get_post_meta( get_the_ID() );
echo “some_image_id = ” . $FullArray[‘someimage_id’][0];$image_attributes = wp_get_attachment_image_src( $FullArray[‘someimage_id’][0], ‘full’ );
var_dump($image_attributes);
echo “Full file name = ” . $image_attributes[0];$image_attributes = wp_get_attachment_image_src( $FullArray[‘someimage_id’][0], ‘medium’ );
var_dump($image_attributes);
echo “Medium file name = ” . $image_attributes[0];‘Full’ doesn’t return the original image though but one with ‘scaled’ in the name but I’m sure I can sort that out.
Thank you so much for your help.
Steve
Forum: Plugins
In reply to: [CMB2] Unable to display image urlOK thanks Michael, I’ll take a look.
Steve
Forum: Plugins
In reply to: [CMB2] Unable to display image urlHi Michael,
Thank you so much for your reply.
I tried a var_dump, the output was the template name:
C:\Users\Steve\Local Sites\wpsitebow\app\public\wp-content\themes\wpsitebow\template-parts\custom-page-demo\custom-template-page.php:21:string ” (length=0)Anything else I can try?
Best Regards,
Steve
Forum: Themes and Templates
In reply to: [Weaver] [Theme: Weaver] Display post titlesFurther to my question.
The exact template is below.
I am not very familiar with PHP, but this templete does refer to the title. I’ve tried inserting the code to display the title in the loop-pwp.php file, but a paragraph <p> is inserted after the title separating it from the article, I suppose I could go deeper in the the functions but surely there should be an easier way.
Any help greatly apprectiated.
Steve
<?php
/**
* Template Name: Page with Posts (title)
*
* This is the template that displays all pages by default.
* Please note that this is the wordpress construct of pages
* and that other ‘pages’ on your wordpress site will use a
* different template.
*/
?>
<?php
global $wp_query;
global $weaver_loop;
get_header();
$paged = weaver_get_page();if (weaver_is_checked_page_opt(‘ttw_hide_sidebars’)) echo(“<div id=\”container\” class=\”one-column page-with-posts page-with-posts-title\”>\n”);
else echo(“<div id=\”container\” class=\”page-with-posts page-with-posts-title\”>\n”);weaver_put_wvr_widgetarea(‘sitewide-top-widget-area’,’ttw-site-top-widget’);
weaver_put_wvr_widgetarea(‘top-widget-area’,’ttw-top-widget’,’ttw_hide_widg_posts’);
weaver_put_perpage_widgetarea();
?>
<div id=”content”>
<?php
// First, put any content from the static page (code derived from page.php template)
if (have_posts()) {
the_post();
if ($paged == 1) { // only show on the first page
ob_start();
if ( is_front_page() ) {
weaver_put_page_title(‘h2’);
} else {
weaver_put_page_title(‘h1’);
}
weaver_page_content(); // get the page content, but don’t display
$page_content = ob_get_clean(); // get the output// now, behave differently if empty.
if (strlen($page_content) > 0) {
?>
<div id=”post-<?php the_ID(); ?>” <?php post_class(); ?>>
<div class=”entry-content”>
<?php echo(“$page_content”); ?>
<div style=”clear:both;”></div>
</div><!– .entry-content –>
<?php edit_post_link( __( ‘Edit’, WEAVER_TRANS ), ‘<span class=”edit-link”>’, ‘</span>’ ); // put here… ?>
</div><!– #post-<?php the_ID(); ?> –>
<?php
}
}$args = array(
‘orderby’ => ‘date’,
‘order’ => ‘DESC’,
‘paged’ => $paged
);
$args = weaver_setup_post_args($args); // setup custom fields for this page$wp_query = new WP_Query();
query_posts($args);$weaver_loop = ‘title’;
get_template_part(‘loop’,’pwp’);
}
?>
</div><!– #content –>
<?php weaver_put_wvr_widgetarea(‘bottom-widget-area’,’ttw-bot-widget’,’ttw_hide_widg_posts’); ?>
<?php weaver_put_wvr_widgetarea(‘sitewide-bottom-widget-area’,’ttw-site-bot-widget’); ?>
</div><!– #container –>
<?phpif (!weaver_is_checked_page_opt(‘ttw_hide_sidebars’)) get_sidebar();
get_footer();
?>