-
Notifications
You must be signed in to change notification settings - Fork 8
Ny cover service #3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
martinb14
wants to merge
1
commit into
ding2:master
Choose a base branch
from
b14:master
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -5,7 +5,7 @@ | |
| */ | ||
| function ting_covers_objects() { | ||
| $covers = array(); | ||
| $missing_images_local_ids = array(); | ||
| $missing_images = $missing_images_local_ids = array(); | ||
|
|
||
| foreach ($_POST['coverData'] as $cover_info) { | ||
| //Reverse cover_info before and after explode to make sure that we explode around | ||
|
|
@@ -24,6 +24,10 @@ function ting_covers_objects() { | |
| } else { | ||
| //Mark the image for retrieval; | ||
| $missing_images_local_ids[] = $local_id; | ||
| if (!isset($missing_images['i_' . $local_id])) { | ||
| $missing_images['i_' . $local_id] = array(); | ||
| } | ||
| $missing_images['i_' . $local_id][$image_style] = TRUE; | ||
| } | ||
| } | ||
|
|
||
|
|
@@ -45,14 +49,19 @@ function ting_covers_objects() { | |
|
|
||
| //No cover image found? Cache this for future reference to avoid unnecessary requests | ||
| if (!$source_url) { | ||
| // foreach ($missing_images['i_' . $local_id] as $image_style => $holder) { | ||
| // $covers[$local_id.':'.$image_style] = image_style_url($image_style, 'public://manual/DEFAULT_COVER_IMAGE.jpg'); | ||
| // } | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Remove comment out code. |
||
| cache_set('ting_covers:'.$local_id, 1, 'cache', $_SERVER['REQUEST_TIME'] + TING_COVERS_CACHE_LIFETIME); | ||
| continue; | ||
| } | ||
|
|
||
| //Try to download the image locally | ||
| if ($file = _ting_covers_pages_fetch_image(ting_covers_object_path($local_id), $source_url)) { | ||
| //Generate a path corresponding to the downloaded image, styled | ||
| $covers[$local_id.':'.$image_style] = image_style_url($image_style, $file->uri); | ||
| foreach ($missing_images['i_' . $local_id] as $image_style => $holder) { | ||
| $covers[$local_id.':'.$image_style] = image_style_url($image_style, $file->uri); | ||
| } | ||
| } | ||
| } | ||
| } catch (Exception $e) { | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -12,9 +12,9 @@ function template_preprocess_ting_object_cover(&$variables) { | |
|
|
||
| //If we already have the image available locally then just use it | ||
| $path = ting_covers_object_path($object->localId); | ||
| if (file_exists($path)) { | ||
| //Generate an alt tag | ||
| //Generate an alt tag | ||
| $alt = implode(', ', $object->creators).': '.$object->title; | ||
| if (file_exists($path)) { | ||
|
|
||
| $variables['image'] = theme('image_style', array('style_name' => $variables['image_style'], 'path' => $path, 'alt' => $alt)); | ||
|
|
||
|
|
@@ -24,6 +24,8 @@ function template_preprocess_ting_object_cover(&$variables) { | |
| //We know that there is no cover available for this object so avoid | ||
| //further javascript processing | ||
| $variables['classes'][] = 'ting-cover-processed'; | ||
| // $variables['image'] = theme('image_style', array('style_name' => $variables['image_style'], 'path' => 'public://manual/DEFAULT_COVER_IMAGE.jpg', 'alt' => $alt)); | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Remove comment out code. |
||
|
|
||
| } | ||
| } | ||
|
|
||
|
|
||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove comment out code.