DEV Community

loading...
Cover image for Wordpress

Wordpress

gitegobrian profile image gitego-brian Updated on ・2 min read

We're nearing the end of the Task Force and we're as enthusiastic as we were the first week.

Personally, this week has been especially challenging for me as my teammate and I had a wordpress task that tested and is still testing my skills.

Basically what we had to do was make it so that the client could be able to change logos on different pages specifically without affecting other pages. At first we used a plugin called Logo or Image replace by mycore.global. What this plugin does is add a meta box on a page with two fields, one for the the src for an image on the page, and another for the src of an image to replace that. This worked kinda good enough for the time but it had a flaw which was that the replacement process was done by client javascript and hence happened after the page was rendered. The problem this creates is that when the page loads, for a split second you can see the original logo before it is replaced, depending on a person's connection, this can go up for multiple seconds if the loading is slow.

Another problem is too much plugins are not a best practice in wordpress as they can cause maintenance, copyright and version compatibility issues. I have since used my own custom implementation which is an improvement to the plugin but there was still the issue of rendering.

The solution for this is, theoretically, to make it so that the replacement happens before the page is rendered. I have tried to achieve this by trying to add a filter after the user has entered the replacing logo image address which will replace the logo before the page loads but so far it's not working for some reason. If anyone has any ideas you can reach out in the comments and here is the link to my question on Stack Overflow..

So, this week was generally about that task and we are currently working to implement it better according to the client's feedback. Let's hope it works eventually.

Discussion (0)

pic
Editor guide