Welcome to the Question2Answer Q&A. There's also a demo if you just want to try it out.
+8 votes
1.4k views
in Plugins by

Hi all!

My name is Victor and I want to share with you my first plugin for Question2Answer.

First of all, please note that I'm new here and I have no any experience with Question2Answer. This is why, is not excluded that my opinion may be faulty or contains incorrect thoughts.

So, as you know, to display avatars, Q2A process them using PHP and MySQL. Thus, when a user open a page where are listed some avatars, for every avatar, Q2A will send a SQL query to database and will use the PHP GD to draw the image. And, it doesn’t matter — whether you use QA_BLOBS_DIRECTORY or not.

Personally, I don’t like this behavior because the filesystem handles static files much better and using it, the speed and performance would be much higher. This is why I developed a plugin which fix image URLs by pointing directly to the file on the server, rather than to a PHP script. For example, instead of generating image by:
/?qa=image&qa_blobid=9183935690084324968&qa_size=50

Will be loaded directly from:
/uploads_path/918/9183935690084324968.jpeg

To install this plugin:

  1. Download and extract filesystem-avatar.zip to the ./qa-plugin/ directory
  2. In ./qa-config.php set up QA_BLOBS_DIRECTORY constant


For more information about QA_BLOBS_DIRECTORY, see http://www.question2answer.org/qa/24390. If you have any suggestions or questions — ask them. Also, I’m waiting for more experienced developers who can tell me if I correctly developed the plugin and if my thoughts are correct.

Q2A version: 1.6.3
by
wow, i did not know that you can override core functions directly using a plugin! qa_register_plugin_overrides('qa-filesystem-avatar.php');

Thanks for this valuable information. Now I can take some of the overrides in my advanced theme and put them into a plugin :)
by
I am very glad that I helped you to discover new features of Q2A ;)
by
edited by
Hi thank you !! have you noticed/measured any load time improvement after installing the plugin ?
by
@soufian
I just recently started using Q2A and respectively, I do not have a popular project which uses Q2A and I cannot say exactly how much it would be enhanced productivity.

Anyway, think about it — by default Q2A sends a MySQL request to database and loads the source of image as string, then, using this string, PHP converts it into image and display it to browser (and so for each avatar displayed on the page). But my plugin disable this behaviour and tells the browser to load image directly from server as an ordinary static file.

2 Answers

+1 vote
by
great, thanks. I wonder why it wasn't added as a core feature in q2a 1.6 when file system feature was added. it's appreciated.
by
I also think it strange and hope that in the following versions the avatars processing will be improved.
0 votes
by
Sounds great thanks for sharing, can't get it to work myself I'm using localhost and it's missing out the site's directory.

http://localhost/media/153/15396166734674399798.jpeg

http://localhost/*<-site directory missing->*/media/153/15396166734674399798.jpeg
...