Attempt to get Image URL in D8 Twig
{% set url = file_url(content.field_books_theme_pic['#items'].entity.uri.value) %}


"file_url" needs a URI to convert.

Another options is to go to that fields display settings and change the display option from image to "URL to image". Then you can just render the field value:

{{ content.field_books_theme_pic }}


If you are working in twig template files, the only thing that changes is context. content.something, fields.something, paragraph.something...

If this is a field of type image, what you are looking for is the array key "URI".

I always use {{ dump(whatever | keys) }}. For your case try pasting this into your twig file:

{{ dump(fields.field_books_theme_pic | keys) }}


and see if you can trace down to the uri key (you must have devel enabled and the usual config in local files). If you cant find the uri key in your current setup via the twig template file, then you know you probably need to do some preprocessing to make it available to your template.

Personally, if I feel I need granular markup I would go after the field template itself: "field--field-name.html.twig" for example, and control my markup there. That way, whether I use that field in a view, or a content type, or anywhere, it will always render the same. Plus all I have to do then is print that field in other template files to get the same results.