This lightweight module is a kind of replacement of Insert module for Drupal 8. It allows you to manually insert images right into the text fields.
Unlike Insert, this module obliges you to use pseudo-tokens like [image:DELTA:STYLE]
, that will be replaced with themed images when viewing the entity. Here DELTA
is the index (starting from 0) of the image being inserted, and STYLE
is the name of image style (STYLE
may be omitted; in this case default image will be shown). For example, here is a valid token:
[image:0:thumbnail]
Usage example
1. Manually add pseudo-tokens to text:
2. See themed images on the site:
Configuration
This module provides a text filter, which should be configured before using:
- After installation, go to http://YOURSITE/admin/config/content/formats and click Configure for text format you want to set up.
- On the text format configure screen, under Enabled filters section, check Insert Images option.
- Below, under Filter settings section, choose Insert Images tab and specify name of the field that contains images you want to insert (for example, field_inline_images).
Configuration screen:
Alternatives
Token Filter module provides much more control on what you have in your text fields. It's a much more general solution, but less convenient if you just want to quickly insert (themed) images.
Entity Embed module is much more general and powerful solution providing similar result under certain conditions. But it is designed to be used with CKEditor and allows less theming flexibility.
Developers notes
Images being inserted can be easily themed using insert_image
theme. Override default insert-image.html.twig
template (which is just shows <img>
tag) if you need.
Following template suggestions are supported out of the box:
insert-image--ENTITY_TYPE.html.twig
insert-image--ENTITY_TYPE--ENTITY_BUNDLE.html.twig
insert-image--ENTITY_TYPE--ENTITY_BUNDLE--VIEW_MODE.html.twig
For example, if you want to style images inserted in nodes of type "Article" when being viewed in "Full" view mode, use insert-image--node--article--full.html.twig
template.
Project Page
https://www.drupal.org/sandbox/stanag/2828619
Git clone
git clone --branch 8.x-1.x https://git.drupal.org/sandbox/stan.ag/2828619.git insert_image
cd insert_image
Comment | File | Size | Author |
---|---|---|---|
#9 | 2017-03-14_10-09-19.png | 26.2 KB | trangunghoa |
3. See images.png | 347.6 KB | stan.ag | |
2. Add pseudo-tokens to text.png | 139.86 KB | stan.ag | |
1. Enable filter.png | 138.89 KB | stan.ag |
Comments
Comment #2
PA robot CreditAttribution: PA robot commentedFixed the git clone URL in the issue summary for non-maintainer users.
We are currently quite busy with all the project applications and we prefer projects with a review bonus. Please help reviewing and put yourself on the high priority list, then we will take a look at your project right away :-)
Also, you should get your friends, colleagues or other community members involved to review this application. Let them go through the review checklist and post a comment that sets this issue to "needs work" (they found some problems with the project) or "reviewed & tested by the community" (they found no major flaws).
I'm a robot and this is an automated message from Project Applications Scraper.
Comment #3
icurk CreditAttribution: icurk commentedManual Review
If added, please don't remove the security tag, we keep that for statistics and to show examples of security problems.
This review uses the Project Application Review Template.
I tested the module and all works as described above.
Comment #4
klausi@icurk: looks like you forgot to change the status. Is this now RTBC after your review or are there application blockers left and this should be set to "needs work"?
Comment #5
icurk CreditAttribution: icurk commentedComment #6
PA robot CreditAttribution: PA robot commentedClosing due to lack of activity. If you are still working on this application, you should fix all known problems and then set the status to "Needs review". (See also the project application workflow).
I'm a robot and this is an automated message from Project Applications Scraper.
Comment #7
stan.ag CreditAttribution: stan.ag as a volunteer commentedComment #8
stan.ag CreditAttribution: stan.ag as a volunteer commentedThanks for review icurk! I added Entity Embed as an alternative to the module description. It provides similar result under certain conditions. Meanwhile, it is designed to be used mostly by users, while my module is mostly for site builders and developers. This means:
<drupal-entity ...>
tag manually, but no one will do this :)Personally for me this small module was preferable over other more general and powerful solutions on some my projects. Maybe it will be so for some other people :)
Comment #9
trangunghoa CreditAttribution: trangunghoa commentedAutomated Review
https://pareview.sh/node/160
Manual Review
Individual user account
No, I think you should add how to use in the README.md
No duplication
Yes
Master Branch
Yes
Licensing
No
3rd party assets/code
Yes
README.txt/README.md
Yes
Code long/complex enough for review
Yes
Secure code
[Yes: Meets the security requirements. / No: List of security issues identified.]
Coding style & Drupal API usage
When I setup in the admin/config/content/formats
and add an article, it's worked.
But I come back the admin/config/content/formats
change Field name from field_inline_images to field_inline_images1
it's show error.
Comment #10
apadernoTo the reviewers: Please change back the priority to Normal after doing a review.
Comment #11
sleitner CreditAttribution: sleitner commentedAutomated Review
Review of the 8.x-1.x branch (commit 6a888f2):
hook_help()
. See https://www.drupal.org/docs/develop/documenting-your-project/module-docu... .This automated report was generated with PAReview.sh, your friendly project application review script.
Manual Review
The starred items (*) are fairly big issues and warrant going back to Needs Work. Items marked with a plus sign (+) are important and should be addressed before a stable project release. The rest of the comments in the code walkthrough are recommendations.
If added, please don't remove the security tag, we keep that for statistics and to show examples of security problems.
This review uses the Project Application Review Template.
Comment #12
apadernoIf you are still working on this application, you should fix all known problems and set the status to Needs review. (See also the project application workflow.)
Please don't change status of this application if you aren't sure you have time to dedicate to this application, or it will be closed again as won't fix.
I am closing this application due to lack of activity.