Skip to content

Disable image viewer for futured image and more #567

Answered by razonyang
iamgiannisx asked this question in Q&A
Discussion options

You must be logged in to vote

Hi, the theme provide a viewer options file, just create the assets/viewer/js/options.ts file to your site root.

The following code snippet ignores the featured images that have class post-featured-img, change it as you need.

const options = {
    filter(img: HTMLImageElement) {
      let valid = !img.classList.contains('post-featured-img');
      if (!valid) {
        img.setAttribute('data-viewer-invisible', 'true');
      }
      return valid
    },
};
export default options;

Available options can be found at https://github.com/fengyuanchen/viewerjs/blob/main/README.md#options.

NOTE: the filter will override the theme's default filter function.

Replies: 1 comment 3 replies

Comment options

You must be logged in to vote
3 replies
@iamgiannisx
Comment options

@razonyang
Comment options

@iamgiannisx
Comment options

Answer selected by razonyang
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants