• Resolved Michel

    (@michel92)


    I’m really stuck with this url story of pictures attached to a quiz.
    I see the URLs for the images are in the wp_post table.
    But it’s quite complicated, because in column L, there is the name of the file, in column S the URL, in column V “image / png”, and other essential parameters are in the other columns .
    What I would like is that I could easily add the URLs of the images included in the questions (not in the answers) after importing the csv file containing the text of the questions. This would avoid having to add each image one by one for each question. I have hundreds of images in stock waiting to be included in the questions …

    So my question is: Is it possible to add somewhere the URLs of the images placed in the questions when importing the csv file of a quiz?
    I know exactly every URL corresponding to every image for every question.
    The ideal would be to add the URLs to a place in the csv file that you import, like you do with the titles, questions and answers.

    Is this option planned in a future Premium version of the extension?

    Can you develop (by paying) this option?

    I looked in the PHP files for the plugin, but nowhere do I see the term “wp_post” (not even in csv_import.php). I don’t understand how you manage to add the data from the csv file to the wp_post tables. Does WordPress perform this task automatically?

    Thanks a lot again for this excellent plugin!

Viewing 1 replies (of 1 total)
  • Plugin Author Harmonic Design

    (@harmonic_design)

    HD Quiz does not upload and handle the images, WordPress does. What I do with HD Quiz is hook into WordPress’ native media uploader and then use all native WP functions to create thumbnails and spit out the correct image sizes based on screen size and stuff. This is why the images also appear in the Media Library. So the only thing that HD Quiz saves as part of the image meta is the ID of the uploaded image.

    So if you want to update question featured images by editing the database (or the csv importer), you first need to know what the ID of the image is that you want to upload.

    If you take a look at hd-quiz/includes/functions.php starting on line 32 you will see a function called hdq_get_attachment_id. This is a function that attempts to lookup up an image URL and return the ID. I wrote this function for users who updated from a super old HD Quiz version to a modern one. Your results will be varied with this, but a suggestion is that you could do the following.

    1. Upload all of your images to the Media Library.
    2. Based on WP naming schemes, you can determine what the URL of each image will be. Example: ./wp-content/uploads/2020/11/image-name.jpg.
    3. Modify the HD Quiz bulk uploader to accept an additional field for URL
    4. Before saving the question, use send the image URL to the hdq_get_attachment_id function to get the image ID.

    This is something that will NEVER be integrated into HD Quiz directly because it is unreliable by design. It may work perfectly 100% for you, but not at all for another user. Or it might work for some images but not others. It is fully dependent on the image being in the WP database. The truth is that I simply don’t want to deal with the flood of support requests that would emerge if I ever released this as an actual feature haha.

    If you need help implementing or testing the above, please feel free to shoot me an email and we can talk about building this in custom just for you ??

Viewing 1 replies (of 1 total)
  • The topic ‘URL of images included in the questions’ is closed to new replies.