Jump to content

Text area field with responsive images (bootstrap)


Marcel
 Share

Recommended Posts

Hey, 

I am very new to processwire and bootstrap. I have a field (text area) and there I want to be able to insert an image which is responsive. I tryed it with Source but in the end the page doesn't seem to like it when I insert in Source the following code

<img src="<?php echo $homepage->content_img->url; ?>" class="img-fluid" alt="Responsive image">

What can I do to make it possible to insert reponsive images in a text area?

Thank you in advance.

Marcel

Link to comment
Share on other sites

I believe you could achieve this by "Extra Allowed Content" under the input tab for the field itself. I have mine set up with :

img[*]

In your source code (after you have uploaded and image to the ckeditor field), you could then simply add in class="img-fluid" and it would then retain the class. Then in you actual code for the template, just use:

<?= $page->your_field_here; ?>

and the content/image will be output with the correct classes to make it responsive.

  • Like 1
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...