Categories
WordPress

Hide featured image if it’s in the post

I’ve been running a photoblog at inphotos.org since 2005 on WordPress. (And thanks to writing this I noticed it’s 15 years old today!)

In that time WordPress has changed dramatically. At first I used Flickr to host my images, but after a short time I hosted the images myself. (Good thing too since Flickr limited free user accounts to 1000 images, so I wrote a script to download the Flickr images I used in posts.)

For quite a long time I used the featured image instead of inserting the image into the post content, but then about two years ago I went back to inserting the photo into the post. Unfortunately that meant the photo was shown twice, once as a featured image, and once in the post content.

The last theme I used supported custom post types, one of which was a photo type that displayed the featured image but hid the post content. It was an ok compromise, but not perfect.

Recently I started using Twenty Twenty, but after 15 years I had a mixture of posts with:

  • Featured image with no image in the post.
  • Featured image with the same image in the post.

I knew I needed something more flexible. I wanted to hide the featured image if it also appeared in the post content. I procrastinated and never got around to it until this evening when I discovered it was actually quite easy.

Copy the following code into the function.php of your child theme and you’ll be all set! It relies on you having unique filenames for your images. If you don’t then remove the call to basename(), and that may help.

function maybe_remove_featured_image( $html ) {
        if ( $html == '' ) {
                return '';
        }
        $post = get_post();
        $post_thumbnail_id = get_post_thumbnail_id( $post );
        if ( ! $post_thumbnail_id ) {
                return $html;
        }

        $image_url = wp_get_attachment_image_src( $post_thumbnail_id );
        if ( ! $image_url ) {
                return $html;
        }

        $image_filename = basename( parse_url( $image_url[0], PHP_URL_PATH ) );
        if ( strpos( $post->post_content, $image_filename ) ) {
                return '';
        } else {
                return $html;
        }
}
add_filter( 'post_thumbnail_html', 'maybe_remove_featured_image' );

The post_thumbnail_html filter acts on the html generated to display the featured image. My code above gets the filename of the featured image, checks if it’s in the current post and if it is returns a blank string. Feedback welcome if you have a better way of doing this!

Categories
Music

James Last plays the Beatles

In the mid 80’s I found a cassette tape of Beatles music played by the James Last orchestra. While I sort of knew some of the music this was the first time I heard many of the songs and I preferred this orchestra version to the original!

The next time the Beatles would intrude on my life would be when I watch Red Storm for the first time in the early nineties.

I guess I have a thing for instrumental Beatles music. 🙂

Categories
C64

Solar Jetman on the C64

This is a game I’d forgotten about until recently when I saw someone playing it on Twitch. Solar Jetman came out on the NES in 1991, and conversions were made for the C64, Speccy, Amiga and Atari ST. Unfortunately due to poor sales of the NES original the conversions were never released.

Luckily the team at Games That Weren’t were contacted by Martin Holland, someone who knew about the game’s development.

GTW got to work and began to search for this elusive conversion, and started with Haydn Dalton, who sadly could not find anything of the game after some searching. Two years later, and a month or two after the site relaunch, efforts were made to find the game’s programmer, John Buckley as a last ditch effort. After tracing John down to PlaypoolUK, GTW got the news it dreaded.. John hadn’t got any of his old disks no longer…
But a week or two after almost giving up hope of finding the game, Haydn Dalton was one day searching through some things at home, when he stumbled upon a disk with the label missing. The label was in there too, and stated “Solar Jetman Disk 1�?, and after a bit more digging, Haydn found the second disk.

GTW

It’s a fascinating story of digital archaeology and the game now be found in various places including the Solar Jetman page on GTW! You can play the original version on archive.org, but Triad released an excellent version that packed the game into one disk side, and trained it too.

The game itself is like Thrust or Lunar Lander, but it came later and is much better than both! Controls are easier and enemies are more varied so if you liked those games you need to try Solar Jetman.

The conversion is missing a few things present in the NES version, and apparently the maps are a little cut down from the original. I need to download the NES version and give it a spin too!

Blow the Cartridge

What do you see when the game ends? Vinny has the answer and posted it on the (old) C64 Game Endings site here.

I discovered an interview with John Buckley, the developer who worked on the C64 version.

What were your first and last ever productions on the C64?
The first thing I did on the C64 was called Jeep Command. I did this in my spare time including the graphics and sound FX. If you have seen it, you will know I ain’t no artist! I sent it off to Bug Byte I think, and they put some music on it and shipped it out. The last thing I did was Solar Jetman, which never got released… until now.

Out of all the games you have worked on, which were you most proud and disappointed with?
I can’t say I am disappointed with anything I worked on. Most of them were conversions, some I wish I hadn’t of worked on but such is life. I liked working on Solar Jetman on the C64 but overall I am most proud of PLOK on the SNES.

Interview with John Buckley on C64.com
Categories
C64

Before I knew about revision control

Going through some of my old C64 discs and I found a bunch of “work in progress” demo parts and routines I was playing with.

Back then I didn’t know about revision control but it was a pleasure to find these bits and pieces of code that I had completely forgotten about. Here’s a few screenshots from Vice, but it’s shocking the difference between Vice and real hardware. The cascading Ozone logo is very pale compared to what I see on another screen. Could it be the screen? Or is it the emulator?

These were found on disc 23, side 1. All those discs are littered with small files, chunks of code that I was working on before throwing them together in the Action Replay monitor.

Kids these days are spoiled with their fancy editors. 🙂

Categories
Humour Youtube

Did Somebody Mention Cork?

Regional accent discrimination? Foil Arms & Hog show are spot on with their accents!

Categories
Science

Rebooting the Apollo Guidance Computer

If you can’t get enough of the Apollo missions after my last post watch as the Apollo Guidance Computer (AGC) is booted up. See inside the machine at the ropes used to store information and marvel at all the little wires that made the landing on the Moon possible.

For more check out this playlist on Youtube.

If that’s not enough I highly recommend listening to episode 220 of The Oribital Podcast. It has an excellent interview with Ron Burkey that will have you enthralled (well, maybe, if you’re like me and find the archaeology of old software interesting!)

The episode show notes link to scans of the original source code and transcribed copies of the code on Github!

Find scans of the source code above on archive.org and the same code is on Github too!

Categories
C64

An Intro to 6502 Assembler

In the bad old days of the 80s and 90s computers weren’t as fast as they are now. You had to fill ’em up with leaded fuel and they were noisy and hot and you had to keep the windows open to let the fumes out.

Well, maybe not. They weren’t as fast as the handheld machines in our pockets now but I’ll bet that a larger percentage of users back then at least tried to code something. People had to because it wasn’t always easy to get games. You had to go down the shops and get out of the house to buy any new software! You had to open the manual to find out how to load anything!

So it was that I figured out that I’d rather be coding than playing games, and with the purchase of a book on assembly (that has sadly gone missing in the last year) I got busy and created a bunch of demos on the C64.

I wish I’d had this video to watch when I was starting out! If you’ve done any sort of assembly programming it won’t be anything new but it’s presented in an easy to understand manner and is worth watching if you’re at all curious about how computers work because a lot of the terminology is going to apply to other systems too.

I’m really looking forward to seeing the rest of this series. I want to get back to doing some assembly programming. There’s plenty of documentation out there but it’s a matter of finding the time and energy to do it.

Categories
C64

We Come in Peace Demo

This is just amazing. All done on a lowly C64 by Censor Design and Fairlight. Grab the demo from csdb. Unfortunately it doesn’t work in the SD2IEC because it has a fastloader. I should buy an Ultimate II+ or Ultimate 64 shouldn’t I?

Categories
C64

C64 Spotted in Cash Connectors

In Cash Connectors, North Main Street Cork. €119.99 for a C64, datasette and I think 4 games. No mention of whether it’s working or not or even if it comes with a power supply.

First time I’ve seen a C64 in a shop here in years. Last time might have been in Maddens on Princes Street some time in the early nineties.

Categories
C64

New C64 Adventures

It’s no secret that I’ve been a fan of the Commodore 64 for many years. It was my family’s third computer, after a Vic20 and 48K ZX Spectrum. I don’t count the Telesport, I couldn’t program that! The C64 was my main computer from 1989 to about 1994 and I went from programming in BASIC to exploring the depths of the machine with an Action Replay cartridge and programming demos in assembly. Since the late nineties I contented myself by using different emulators like PC64, Frodo and Vice but in the last year or so I’ve wondered about owning one again.

What I would consider the first resurgence of the C64 world for me was finding the Commodore Format blog. There’s also Zzap64.co.uk which has been going for ages but it’s an invaluable archive site. The CF blog has regular blog posts about this old magazine and features about new developments and I love it. I could blame the community of C64 fans on Twitter, the C64 sub Reddit and various C64 groups on Facebook. They’re always going on about playing this game or that game on “real hardware”, or how a certain demo doesn’t look perfect in an emulator. But really, I’d say it was the fanzine FREEZE64 that finally piqued my interest again. It’s a great read and Vinny, who publishes it, is always posting photos of the things he’s doing on the machine. The fanzine brings me back 30 years to when I first got the machine.

Peer pressure finally won. I bought a C64 on eBay and it arrived yesterday!

I’ve always wondered if it was possible to use a modern controller with the C64 and there are a few adaptors to do that. One of those is the TOM Rev2 adaptor and extension cable. It’s due to arrive at the end of the month, so fingers crossed it works well.

I have a 1541 II disk drive in the attic but there are better storage solutions available for the C64 now. One of those is the SD2IEC, an SD card reader for the machine. I bought the thefuturewas8bit SD2IEC and Fastload Cartridge. Conveniently an 8GB SD card can be purchased which is enough room to fit practically every C64 game on it!

The C64 produces a composite video signal and a video signal that was s-video before that was even a standard. My monitor doesn’t have either RCA/phono sockets, SCART or s-video port but it does have HDMI so I needed a converter. Scouring websites and forums for information about the best way to connect a C64 to HDMI is exhausting. Recommendations to buy one converter are followed by discouraging remarks from others about the same device. In the end I checked Amazon reviews and this Ex-Pro video converter seemed to fit the bill. It has phono and s-video sockets too!

Finally, I needed a video cable. I messed up and bought a C64 DIN to phono/RCA cable instead of s-video, but it works well enough. The screen image is nowhere near as clear as an emulator like Vice but I’ve ordered a similar cable with an s-video plug that I hope will be better.

The first thing I tried was one of my demos, Bits ‘n’ Bobs and it was amazing to see it run! The picture isn’t perfect and especially on this wide monitor everything is stretched. 4:3 it is not!

In a later demo, the CFORCE demo, I displayed a FLI picture in one part. That picture annoyingly bounced up and down which is probably a result of displaying on a modern monitor. On an old CRT it was fairly solid, apart from the usual fuzziness when displaying FLI pictures.

Getting it all set up was a challenge, mainly to find space for it, but I made room. Using the “picture in picture” mode of my monitor the display is smaller and the effects of the component cable less noticeable.

The SD2IEC and fastloader cartridge are a game changer. No more fiddling with ageing physical disks that are likely to be unreadable. I’m already missing the Action Replay though. F1 to load and F3 to list a disk is just that tiny bit more convenient than the Epyx Fastloader equivalents.

I just bought an Over Voltage Protector as I’m paranoid. This machine came with a Micro Mate power supply but power supplies fail and the C64’s chips are sensitive to more than 5.5V. This should hopefully stop that happening if the PSU fails.

Now I’ve got one of these machines I want to get an Ultimate 64. It’s a fascinating bit of kit, and the price of it put me off before, but it’s actually cheap when you consider everything it does!

So, what games should I play on it? I’m without a joystick or controller so it’s keyboard only. I asked on Twitter and I have to try Thrust, The Sentinel, West Bank, Skooldaze and the recently released Neutron on it as they all support keyboard. I already played Stunt Car Racer which brought back plenty of memories. 🙂

Edit: The s-video cable arrived and the video quality is much better. There’s still faint vertical lines but I can live with those.

Edit on 12th June: I just received this female RCA to 3.5mm earphone jack and I can finally hear the SID on decent speakers! The sound from my HDMI monitor is woeful so I’ve been looking forward to this for a while.