Category: Uncategorized

  • BUTTS

    BUTTS

    echo $(echo 66 85 84 84 83 | awk '{for(i=1;i<=NF;i++) printf "%c", $i}')

  • Limiting Featured Image Dimensions in WordPress

    Limiting Featured Image Dimensions in WordPress

    As a follow up to my last post about limiting file sizes during uploads, I had to come back to the problem with limiting image sizes for featured images. Not bytes this time, but pixel dimensions.

    Still being a bit of a block editor newb, this was an interesting challenge for me, and I was really surprised at how easy it was to implement. I basically googled around and found a few different things to put together that worked for me. The primary source was a post by Igor Benic on how to disable the publish button:

    After that, I discovered how to add notifications to the block editor, to tell when the image was too large, thanks to a post by David F. Carr:

    So what’s it look like? Well, it’s pretty simple. If you choose a featured image that’s too large for the settings, it will add a non-dismissible error notification to the editor:

    Then it will block you from hitting the publish button:

    So, finally the code. This is just enqueued in as a simple add_action() during the enqueue_block_editor_assets hook. I’m absolutely not a good JS developer, so please don’t judge me too harshly. Also, that means this could be riddled with bugs. Use at your own risk πŸ˜€

    var postLocked = false;
    wp.domReady( () => {
    	wp.data.subscribe( function() {
    		var imageId = wp.data.select( 'core/editor' ).getEditedPostAttribute( 'featured_media' ); // Featured Image ID.
    
    		// If we have no image ID, and we already locked the post, we won't do anything.
    		if ( imageId ) {
    			blockEditorSettings = wp.data.select('core/block-editor').getSettings();
    
    			// Default to 1200px wide.
    			maxImageSize = 1200;
    			imageAttrs = wp.data.select('core').getMedia( imageId );
    
    			// Get the size for the "large image" and if it's available, use that instead.
    			if ( typeof blockEditorSettings !== 'undefined' && blockEditorSettings.hasOwnProperty( 'imageDimensions' ) ) {
    				maxImageSize = blockEditorSettings.imageDimensions.large.width;
    			}
    
    			if ( typeof imageAttrs !== 'undefined' && imageAttrs.hasOwnProperty( 'media_details') ) {
    				// Publish is not locked and width is too large.
    				if ( ! postLocked && imageAttrs.media_details.width > maxImageSize ) {
    					postLocked = true;
    					wp.data.dispatch( 'core/editor' ).lockPostSaving( 'featuredImageTooLarge' );
    
    					wp.data.dispatch('core/notices').createNotice(
    						'error', // Can be one of: success, info, warning, error.
    						wp.i18n.__( wp.i18n.sprintf( 'Featured image width must be less than %spx, currently %spx. Publishing is disabled.', maxImageSize, imageAttrs.media_details.width ) ),
    						{
    							id: 'featuredImageTooLarge', // Assigning an ID prevents the notice from being added repeatedly.
    							isDismissible: false, // Whether the user can dismiss the notice.
    						}
    					);
    				}
    
    			}
    		} else if ( postLocked ) {
    			postLocked = false;
    			wp.data.dispatch( 'core/editor' ).unlockPostSaving( 'featuredImageTooLarge' );
    			wp.data.dispatch('core/notices').removeNotice( 'featuredImageTooLarge' );
    		}
    	} );
    } );Code language: JavaScript (javascript)
  • Five Years

    Five Years

    This past Monday marked my five year anniversary at Automattic, working for WordPress VIP. It seems forever ago, but at 9:59AM on February 11, 2015 I emailed jobs@automattic.com with my resume built as a child theme to twentyfifteen. Somehow I must have tricked them because 22 days later (which is pretty fast for a reply from Automattic back then 😬), interviewed, code tested, trialed, and ended up sticking around.

    I’m not going to go through the boring details of how hiring works at Automattic. Many great friends and bloggers better than me have written about it. I would though like to highlight a few of my favorite parts of my five year journey.

    The first few weeks and months were a bit surreal, trying to just get caught up to speed in the chaos. Spring turned into Summer, and I came across my first real moment of panic: Travel.

    I was asked to go to New York to meet with some clients, and attend the BigWP meetup. Now, for those of you that don’t know me, I’m born and raised from Nowhere, USA where we don’t really travel much. Luckily, it ended up great! BigWP was a blast, and meeting up with coworkers in real life, traveling around NY, and visiting clients really set in stone that the work that I was doing mattered to people.

    https://x.com/crushgear/status/643925830742212608

    It wasn’t a month later that I was off again on another adventure: my first Grand Meetup. The Grand Meetup is the once-a-year gathering of everyone from Automattic where we teach, learn, work, play, and really connect. For being a fully distributed company, this face to face time invigorates me more than anything and gets me excited about the work we still have to do. So, in October of 2015 I went to Park City.

    https://x.com/WordPressVIP/status/654794938903691264

    At that time VIP felt like a good size, and tiny in comparison to the larger company of 400 Automatticians:

    Fast forward a few more months and I’m headed to my first team meetup, in Barcelona. By now, I’ve flown a few times, so I’ve got this down, but overseas, that was another frightening first.

    https://x.com/mattoperry/status/694521200240910337

    That meetup in Barcelona, my first meetup, will have a special place in my heart forever. I don’t think anything can replace that feeling of fear, excitement, esprit de corps, and so many other emotions. From having coffee at a cafe at nearly midnight with a couple of friends just chatting about life, to actually working together to build our business plans for the year ahead–even thinking back about it now, it seems surreal.

    Right. Now this was all within the first six months. At this rate, this post will end up a small book. I’ll just hit some yearly highlights

    2016:

    The VIP Workshop in Napa

    https://x.com/WordPressVIP/status/730089745494085632

    BigWP NYC again!

    https://x.com/WordPressVIP/status/760966657787461632

    Whistler Grand Meetup

    https://x.com/ChrisHardie/status/778455679409369088

    2016 Election Traffic Boom, what a night!

    https://x.com/WordPressVIP/status/798268044455936000

    End the year with one more BigWP

    https://x.com/WordPressVIP/status/805918087585337344

    2017:

    Team meetup in Glasgow

    https://x.com/crushgear/status/887610056769982465

    Grand Meetup in Whistler

    https://x.com/andrealee_b/status/909472934825156608

    2018:

    Team meetup in Lisbon

    First VIP Grand Meetup on Montreal

    2019:

    Client meetings in San Francisco

    Team meetup in Playa del Carmen

    https://x.com/automattic/status/1093632259272441856

    Client meetings in New York

    VIP Grand Meetup in Rotterdam

    https://x.com/JoshProTweets/status/1185468743826190336

    2020:

    Team meetup in Athens

    While I love the work that I do, and I find fulfillment in it, what really sets Automattic and WordPress VIP apart is the people. We come from a wide variety of backgrounds and places, and every single person is extremely talented, kind, and just plain amazing. I wouldn’t want to be anywhere else.

    By the way, we’re hiring! πŸ˜‰

  • New Beginning

    I’m trying to force myself to do a few new things:

    • Blog on a schedule
    • Learn new stuff

    Because of that, I’m starting over on derrick.blog and playing around here.  I’ll be testing new WordPress stuff here, especially Gutenberg.

  • Game Developer Barbie

    Game Developer Barbie

    Game Developer Barbie is coding what looks to be a mobile Java-based Candy Crush clone in a Windows XP IDE.

    Sadly, that sounds pretty accurate.

  • This is why I Ad Block

    This is why I Ad Block

    An article served an ad that hijacked my browser and would not let me go back.  I had to kill the Chrome App and started fresh.