Is it possible to backport "uri_callback" in hook_entity_info alter. So as is done in file_entity v2.
This way it is possible to support linkit with media V1.
See corresponding Linkit issuu.

In file_entity.module add

function file_entity_entity_info_alter(&$entity_info) {
$entity_info['file']['uri callback'] = 'file_entity_uri';
 

and add function

/**
 * URI callback for file entities.
 */
function file_entity_uri($file) {
  $uri['path'] = 'file/' . $file->fid;
  return $uri;
}

Such as done in file_entity V2 should probably do the trick.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

mallezie’s picture

Created a patch, and expanded some more info setting. probably not getting in with feature freeze of V1. But i wanted to share. Since it's a solution to make Linkit work with media v1.

Dave Reid’s picture

Status: Active » Needs work

Entity URI callbacks should actually go to the "internal" pages or media/%file and not be using file_create_url().

netsensei’s picture

Status: Needs work » Needs review
FileSize
911 bytes

Needed this too to get Media 1.x working with Linkit.

Per the comment in #2: The patch uses "file/" . $file->fid One could argue if "media/" . $file->fid would be more fitting, but since we're working on a "File entity", I'd honor the "entity-name/" . $id convention.

Rerolled the patch per the comment in #2.

netsensei’s picture

Title: define "uri callback" » Define the "uri callback" in file_entity_entity_info_alter
Dave Reid’s picture

Title: Define the "uri callback" in file_entity_entity_info_alter » Define the "uri callback" for file entities (1.x)
Component: File entity » Code
Status: Needs review » Needs work

Problem is in the 1.x branch there is no such path file/%file. It actually lives at media/%file and is exposed by Media module. And so this uri callback should actually be altered in and owned by the media module.

netsensei’s picture

Taking another stab at this. I've moved the callback to the media module. Linkit keeps working as it should and files are exposed through "media/%file"

netsensei’s picture

Status: Needs work » Needs review

Changing the status.

Status: Needs review » Needs work

The last submitted patch, 1561012-entity-media-uri-callback.patch, failed testing.

ParisLiakos’s picture

Status: Needs work » Fixed

#6 looks good to me
commited

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

attila.fekete’s picture

Status: Closed (fixed) » Needs review
FileSize
433 bytes

Two extra '+' signs were left in the comment section, just made a patch to fix that.

netsensei’s picture

Status: Needs review » Reviewed & tested by the community

Yup. Overlooked those. Patch looks good.

aaron’s picture

Status: Reviewed & tested by the community » Fixed

Thanks for the catch. I've committed it.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.