Automatically generating pages for each thumbnail linked to larger pictures solely for ad space and keyword targeting may be seen as creating doorway pages by Google, potentially leading to penalties. follow Google's advertising guidelines to maintain a positive user experience and avoid penalties
Focus on providing valuable, unique content on each page rather than merely generating pages for the sake of targeting keywords or displaying ads. Each page should offer users something meaningful and distinct, whether it's additional information, context, or insights related to the content they're viewing.
Finally make sure that your website follows Google's guidelines for advertising, including ad placement and density, to maintain a positive user experience.
https://support.google.com/adspolicy...ucts%20here%22