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)
    Embed Button Config
  • 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.
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

drfuzetto created an issue. See original summary.

drfuzetto’s picture

Status: Active » Needs review
Issue tags: -Baltimore Drupalcon 2017 +Baltimore2017
FileSize
3.34 KB

Here is an initial patch that provide a link field to add a url

susannecoates’s picture

I 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

susannecoates’s picture

I 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

drfuzetto’s picture

Issue summary: View changes
FileSize
205.23 KB
drfuzetto’s picture

[@susannecoates], I updated the issue to provide some more details.

camilo.escobar’s picture

I 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"

camilo.escobar’s picture

Additional 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.

camilo.escobar’s picture

FileSize
4.83 KB

Status: Needs review » Needs work

The last submitted patch, 9: 2873754-9.patch, failed testing. View results
- codesniffer_fixes.patch Interdiff of automated coding standards fixes only.

joppy’s picture

other solution for this issue from entity_embed module https://www.drupal.org/project/entity_embed/issues/2511404