surveydown-dev / surveydown

Markdown-Based Surveys Using R, Quarto, and Shiny
https://pkg.surveydown.org/
Other
65 stars 10 forks source link

Images don't display in the survey #107

Closed rgmerck closed 1 month ago

rgmerck commented 1 month ago

Bug description

Hi, thanks for your work on surveydown, excellent tool and concept. I have one issue. I would like to display an image as part of the qmd file to show a picture and ask feedback to the end user on that basis. It looks like it displays just fine in the qmd file when it is a local file, however in the shiny app, it is not rendered, as if the image was missing.

Note that I really need the image to be local to the server and not a remote image using a http address.

Steps to reproduce

add an image in the qmd file using :

![](img_path)

with the image path being on the same folder as the surveydown survey.

Expected behavior

the image should display in the web survey

Actual behavior

the imag does not display

Your environment

Ubuntu 24.04 Rstudio environment

jhelvy commented 1 month ago

Hi! Thanks for giving surveydown a try. I'm going to guess this might just be resource path issue. Not all folders are available to Shiny when you launch the app. If you put your images in a folder called images, then that folder will automatically be added. See here for more.

rgmerck commented 1 month ago

@jhelvy Thanks for the quick answer, much appreciated.

The documentation in your link does not seem to be up to date.

  1. first. the sd_add_folder() function does not seem to exist anymore. Rather, you need to use sd_include_folder() apparently?
  2. It seems like the second part of that page regarding the default folders to be added is also wrong. I added an images folder first, with my picture in it and the proper reference in the qmd file, and it was not recognized. I had to add sd_include_folder("images") for it to display correctly.

Or did I miss something? In any case the documentation you linked may not be up to date for the latest version of the package.

jhelvy commented 1 month ago

Yup, that's a docs error - should be sd_include_folder(). I'll fix that. But not sure why an "images" folder isn't working by default. That is still there in our code. It works by including the default folders when the surveydown package is first loaded, so if you have library(surveydown) at the top of your app.R file it should automatically add the "images" folder.

rgmerck commented 1 month ago

Yup, that's a docs error - should be sd_include_folder(). I'll fix that. But not sure why an "images" folder isn't working by default. That is still there in our code. It works by including the default folders when the surveydown package is first loaded, so if you have library(surveydown) at the top of your app.R file it should automatically add the "images" folder.

I just tried again by commenting out the sd_includer_folder() statement and this time it worked with the images folder... Let me restart in a clean session to double-check.

rgmerck commented 1 month ago

checked again in a clean session, looks like "images" folder actually works! Not sure why I got the issue earlier on. You can close this ticket, I believe.

jhelvy commented 1 month ago

Sweet. And the docs are now corrected.