Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Embedding a media image in ckeditor does not allow you to link media thumbnail to an internal or external url.
The ckeditor link button doesn't allow you to create link to media since the media is not rendered yet.
Modules required other than media_entity: media_entity_image, embed, entity_embed, entity_browser, ctools.
Steps to reproduce:
- Enable all modules listed above.
- Add and configure a media browser. (admin/config/content/entity_browser)
- Add Embed button for media entity type and allow Thumbnail Entity Display Plugin. (admin/config/content/embed)
- Add Entity Embed button to text edit toolbar. i.e. Full HTML. (admin/config/content/formats)
- Create page. Upload image using the Entity Embed button.
- Upload or select image. In the Embed Media config screen, display as thumbnail. There are options to link to media entity or content. The patch in the comment below adds an option to link to URL and provides a link field.
Comment | File | Size | Author |
---|---|---|---|
#9 | 2873754-9.patch | 4.83 KB | camilo.escobar |
| |||
#5 | Screenshot 2017-05-01 09.11.07.png | 205.23 KB | drfuzetto |
#2 | 2873754-2.patch | 3.34 KB | drfuzetto |
|
Comments
Comment #2
drfuzetto CreditAttribution: drfuzetto commentedHere is an initial patch that provide a link field to add a url
Comment #3
susannecoates CreditAttribution: susannecoates as a volunteer commentedI am at DrupalCon and am testing your patch. I have applied the patch (Drupal 8.3.1), but do not see where a url may be supplied for the Thumbnail. Could you provide further instructions.
Thanks,
Susanne
Comment #4
susannecoates CreditAttribution: susannecoates as a volunteer commentedI am at DrupalCon and am testing your patch. I have applied the patch (Drupal 8.3.1), but do not see where a url may be supplied for the Thumbnail. Could you provide further instructions.
Thanks,
Susanne
Comment #5
drfuzetto CreditAttribution: drfuzetto commentedComment #6
drfuzetto CreditAttribution: drfuzetto commented[@susannecoates], I updated the issue to provide some more details.
Comment #7
camilo.escobar CreditAttribution: camilo.escobar as a volunteer commentedI have complemented the patch in #2, including the following improvements:
1. Add the use statement:
use Drupal\node\Entity\Node;
To avoid getting an error in this line:
$default_value = Node::load($nid[1]);
2. If a node is selected in the new "Image URL" field, via auto-completing, then link the image to the alias URL of that node, instead of linking it to "node/xxx"
Comment #8
camilo.escobar CreditAttribution: camilo.escobar as a volunteer commentedAdditional enhancements:
1. Make the new field "Image URL" is marked as required only when the value "URL" is selected in the "Link image to" drop-down. In the patch in #2, the field has 'required' => TRUE, and it is throwing a validation error even when "Content" or "Media entity" is selected in the "Link image to" field.
2. The update in point 1 only adds the required indicator (*), so a new validate function was added to the element: _validateImageUrlNotEmpty_, to ensure the value in field "Image URL" is not empty if the value "URL" is selected in the "Link image to" drop-down.
Comment #9
camilo.escobar CreditAttribution: camilo.escobar as a volunteer commentedComment #11
joppy CreditAttribution: joppy commentedother solution for this issue from entity_embed module https://www.drupal.org/project/entity_embed/issues/2511404