Fallback image when no Post image exists

himahuja's Avatar


05 Mar, 2016 06:42 AM


I am using your wonderful slider on a number of sites. I've gotten so used to the settings that I haven't explored any other options :)

In one of my site, I am using it in a custom post type through ACF to display images from posts in gallery slider. Normally, it works fine as it finds all images related to the post and displays a slider gallery. However, some of the posts do not have any image, and I want to display a fallback branded image instead of a blank on such posts. Is that possible, and how can I achieve this?


  1. Support Staff 1 Posted by Dmitry Semenov on 05 Mar, 2016 07:40 PM

    Dmitry Semenov's Avatar


    Slide markup editor supports conditional tags http://help.dimsemenov.com/kb/wordpress-royalslider-tutorials/wp-us... , you may use them to show fallback content, for example if {{image_url}} is empty.


  2. 2 Posted by himahuja on 09 Mar, 2016 09:14 AM

    himahuja's Avatar

    Thanks Dmitry but my php knowledge is very limited. I understand though, that a conditional statement might be the solution, but the link you gave does not have any example of a conditional statement, that I could play with. I just want to be able to provide link to a default fallback image if there are no images in a post to show in gallery slider.


  3. Support Staff 3 Posted by Dmitry Semenov on 09 Mar, 2016 02:44 PM

    Dmitry Semenov's Avatar
        Content when Image URL defined
        Content when Image URL is not defined
  4. 4 Posted by himahuja on 10 Mar, 2016 08:33 AM

    himahuja's Avatar

    Thanks a lot Dmitry, I tried your code and while the first part is displayed, the second is still not showing up. Here is my code"

    <div class="rsContent">
        <img src="{{image_url}}" class="rsImg">
      Default image
       <div class="centerContainer">
          <div class="centerMe">
                 <div class="rsCaption">  
      <a class="rsLink" href="{{link_url}}">{{title}}</a>

    The first usage in # correctly shows the post images in slider as earlier. But the second usage in ^ inverted does not even display the text. It still shows the "Royal Slider Error: No Images found" message. Could you please look into it?


  5. Support Staff 5 Posted by Dmitry Semenov on 10 Mar, 2016 03:10 PM

    Dmitry Semenov's Avatar

    Oh, I misunderstood you, I thought you want to show fallback for one of the slides, not for whole slider.

    RoyalSlider doesn't have an option to do what you want out of box. You'll need to check via PHP if post has images or not, and do not print [gallery] shortcode if there aren't any images.

  6. 6 Posted by Laavanya on 16 Nov, 2017 07:56 AM

    Laavanya's Avatar

    i am using royal slider full-width template with text , and when there is no image on one of the slider i am not able to view the text also, what i observed is when i am using rsImg class for img tag its getting empty with no background and text even, but when i remove the rsImg text is visible but onload the slider is loading only half. on refresh its showing complete royalslider

  7. Support Staff 7 Posted by Dmitry Semenov on 16 Nov, 2017 08:05 AM

    Dmitry Semenov's Avatar

    @Laavanya, if there is no rsImg class on image - RoyalSlider won't apply any actions to it, so image scaling options won't work http://help.dimsemenov.com/kb/royalslider-jquery-plugin-faq/how-to-...

  8. 8 Posted by Laavanya on 16 Nov, 2017 10:12 AM

    Laavanya's Avatar

    But i am not getting any content inside <div class="rsSlide rsActiveSlide"> for that particular slide.its empty.

  9. Support Staff 9 Posted by Dmitry Semenov on 16 Nov, 2017 03:20 PM

    Dmitry Semenov's Avatar

    @Laavanya, please open a separate private discussion and link to the page with the issue + provide temp admin access if you can.

Reply to this discussion

Internal reply

Formatting help / Preview (switch to plain text) No formatting (switch to Markdown)

Attaching KB article:


Attached Files

You can attach files up to 10MB

If you don't have an account yet, we need to confirm you're human and not a machine trying to post spam.

Keyboard shortcuts


? Show this help
ESC Blurs the current field

Comment Form

r Focus the comment reply box
^ + ↩ Submit the comment

You can use Command ⌘ instead of Control ^ on Mac