Welcome to the Question2Answer Q&A. There's also a demo if you just want to try it out.
+2 votes
2.2k views
in Q2A Core by

I have a site where each question is based on an image.

One uploads the image through the editor, adds the title and question text.

Now in lists I need  the whole question content displayed, includig the images.

(I understand that it slows down the page but I need the pictures visible on the lists...)

What would be the way to do so ?

Any help is welcome !!

 

There was a similar question here, but without answer so far:

http://www.question2answer.org/qa/11764/how-to-show-question-content-to-question-list

Q2A version: 1.5
by
I am interested in this also. I would also like to be able to display icons if the question contains a link, image, or other embedded media.

1 Answer

0 votes
by
selected by
 
Best answer

Use an advanced theme or layer to intercept the q_list(...) theme function and make the change you want. See the mouseover-layer plugin for some clues.

by
Thank You so far !

I found a way by modifying the qa-mouseover-layer.php in the mouseover plugin. But I would prefer to have something similar in the advanced theme.

Hope it works for others:

            //    Now add the popup to the title for each question
       
                    foreach ($q_list['qs'] as $index => $question) {
                        $thispost=@$postinfo[$question['raw']['postid']];               
                        if (isset($thispost)) {
$text=qa_viewer_text($thispost['content'], $thispost['format'], array('blockwordspreg' => $blockwordspreg));
$text=qa_shorten_string_line($text, $maxlength);

//the following line was changed from
// $q_list['qs'][$index]['title']='<SPAN TITLE="'.qa_html($text).'">'.@$question['title'].'</SPAN>';
//to:
$q_list['qs'][$index]['content']='<div>'.$thispost['content'].'</div>';
                        }
                    }
by
EDIT:

Now I could add images to the question lists through advanced theme:

change function q_list($q_list)    to:

function q_list($q_list)
        {
            if (count(@$q_list['qs'])) { // first check it is not an empty list and the feature is turned on

            //    Collect the question ids of all items in the question list (so we can do this in one DB query)
   
                $postids=array();
                foreach ($q_list['qs'] as $question)
                    if (isset($question['raw']['postid']))
                        $postids[]=$question['raw']['postid'];
               
                if (count($postids)) {

                //    Retrieve the content for these questions from the database and put into an array
               
                    $result=qa_db_query_sub('SELECT postid, content, format FROM ^posts WHERE postid IN (#)', $postids);
                    $postinfo=qa_db_read_all_assoc($result, 'postid');
                   
                //    Get the regular expression fragment to use for blocked words and the maximum length of content to show
                   
                    $blockwordspreg=qa_get_block_words_preg();
                    $maxlength=qa_opt('mouseover_content_max_len');
                   
                //    Now add the popup to the title for each question
       
                    foreach ($q_list['qs'] as $index => $question) {
                        $thispost=@$postinfo[$question['raw']['postid']];
                       
                   
                                   
                        if (isset($thispost)) {
                           
$text=qa_viewer_text($thispost['content'], $thispost['format'], array('blockwordspreg' => $blockwordspreg));
                            $text=qa_shorten_string_line($text, $maxlength);
                        //  $q_list['qs'][$index]['title']='<SPAN TITLE="'.qa_html($text).'">'.@$question['title'].'</SPAN>';
                            $q_list['qs'][$index]['content']=$thispost['content'];
                        }
                    }
                }
            }


Then add to NOAHs embed plugin to qa-embed-layer.php :


    function q_item_content($q_item)
        {
            if (isset($q_item['content'])){
                $q_item['content'] = $this->embed_replace($q_item['content']);
            }
            qa_html_theme_base::q_item_content($q_item);
        }       


I really dont know if this is errorfree, but at least it works.

Now I can show on each questionlist uploaded images or embedded youtube movies.
by
do you have example of this how it looks?
by
Yes, look here: http://www.yamemes.com

It is not perfect, as too large images are not resized automatically.
You may upload something funny and try it out...
by
Looks good.
My requirements are to add thumbnails from questions and also from answers so I will definitely need some custom solution to find on freelancer or somewhere.
by
You may click on SUBIR ALGO this is the replaced ASK button.
There is a possibility to have the image resized through css to Your fixed thumb dimensions, but I still didnt work with that, as the page was just a trial and is not perfect.

Answers should be similar.

So one basically needs to implement that css resizing and build something similar for the answers.

I already tried to modify the ckeditor so that it uses predefined max dimensions but I couldnt and I as well did not find anybody who resolved that. It would be helpful, as one could reduce the upload form to a single dialog window.

I would go ahead with a foto comment page, but actually I am not really happy about storing allways the huge images into the database.

Besides, I would be happy to see what You are working on, just to understand Your needs, You may email me if You want or allowed to...
by
Please, paste the code, pastebin..
...