Skip to content

Commit

Permalink
WF Image src urls set in wf_core.php - update tinymce insert too
Browse files Browse the repository at this point in the history
  • Loading branch information
majic3 committed Mar 17, 2010
1 parent 4812de5 commit 8a43327
Show file tree
Hide file tree
Showing 8 changed files with 28 additions and 12 deletions.
5 changes: 3 additions & 2 deletions app/config/routes.php
Expand Up @@ -36,8 +36,9 @@

// Image thumbnails
// @TODO shorten to '/i/*'
Router::connect('/wildflower/thumbnail/*', array('controller' => 'assets', 'action' => 'thumbnail'));
Router::connect('/wildflower/thumbnail_by_id/*', array('controller' => 'assets', 'action' => 'thumbnail_by_id'));
$mprefix = Configure::read('Wildflower.mediaRoute');
Router::connect('/'.$mprefix.'/thumbnail/*', array('controller' => 'assets', 'action' => 'thumbnail'));
Router::connect('/'.$mprefix.'/thumbnail_by_id/*', array('controller' => 'assets', 'action' => 'thumbnail_by_id'));

// Search
Router::connect('/search', array('controller' => 'dashboards', 'action' => 'search'));
Expand Down
1 change: 1 addition & 0 deletions vendors/wf_core.php
Expand Up @@ -22,6 +22,7 @@
'rootPageCache' => CACHE . 'wf_root_pages',
'previewCache' => CACHE . 'wf_previews',
'thumbnailsCache' => CACHE . 'wf_thumbnails',
'mediaRoute' => 'i',
'postsParent' => 'p',
'blogIndex' => 'blog',
// Disabling the root page cache may be useful in debugging
Expand Down
4 changes: 2 additions & 2 deletions wildflower/jlm/controllers/components/tiny_mce.js
Expand Up @@ -102,10 +102,10 @@ $.jlm.addComponent('tinyMce', {
resizeHeight = resizeWidth;
}
if (intval(resizeHeight) > 1) {
imgUrl = $.jlm.base + '/wildflower/thumbnail/' + imgNameEscaped + '/' + resizeWidth + '/' + resizeHeight + '/' + crop;
imgUrl = $.jlm.base + '/'+$.jlm.wildflowerMPreix+'/thumbnail/' + imgNameEscaped + '/' + resizeWidth + '/' + resizeHeight + '/' + crop;
}

// Image HTML
// Image HTML - needs to handle class & alt
var imgHtml = '<img alt="' + imgName + '" src="' + imgUrl + '" />';

$.jlm.components.tinyMce.editor.execCommand('mceInsertContent', 0, imgHtml);
Expand Down
3 changes: 2 additions & 1 deletion wildflower/views/assets/admin_edit.ctp
Expand Up @@ -10,7 +10,8 @@ echo $navigation->create(array(
// If file is image display it fitting the wrap
$isImage = (strpos($this->data['Asset']['mime'], 'image') === 0);
if ($isImage) {
echo $html->image("/wildflower/thumbnail/{$this->data['Asset']['name']}/600/1000"),
$mprefix = Configure::read('Wildflower.mediaRoute');
echo $html->image("/$mprefix/thumbnail/{$this->data['Asset']['name']}/600/1000"),
'<p class="image-resized-notice">This image is resized. ',
$html->link("View the original image.", '/uploads/' . $this->data['Asset']['name']),
'</p>';
Expand Down
6 changes: 4 additions & 2 deletions wildflower/views/assets/admin_index.ctp
Expand Up @@ -9,7 +9,9 @@
<?php echo $this->element('admin_select_actions'); ?>

<ul class="file-list list">
<?php foreach ($files as $file): ?>
<?php
$mprefix = Configure::read('Wildflower.mediaRoute');
foreach ($files as $file): ?>

<li id="file-<?php echo $file['Asset']['id']; ?>" class="actions-handle">
<span class="row-check"><?php echo $form->checkbox('id.' . $file['Asset']['id']) ?></span>
Expand All @@ -21,7 +23,7 @@
?>

<a class="thumbnail" href="<?php echo $html->url(array('action' => 'edit', $file['Asset']['id'])); ?>">
<img width="50" height="50" src="<?php echo $html->url("/wildflower/thumbnail/{$file['Asset']['name']}/50/50/1"); ?>" alt="<?php echo hsc($file['Asset']['title']); ?>" />
<img width="50" height="50" src="<?php echo $html->url("/$mprefix/thumbnail/{$file['Asset']['name']}/50/50/1"); ?>" alt="<?php echo hsc($file['Asset']['title']); ?>" />
</a>

<h3><?php echo $html->link($label, array('action' => 'edit', $file['Asset']['id'])); ?></h3>
Expand Down
15 changes: 12 additions & 3 deletions wildflower/views/assets/admin_insert_image.ctp
Expand Up @@ -6,11 +6,13 @@
<?php else: ?>

<ul class="file-list list">
<?php foreach ($images as $file): ?>
<?php
$mprefix = Configure::read('Wildflower.mediaRoute');
foreach ($images as $file): ?>

<li id="file-<?php echo $file['Asset']['id']; ?>" class="actions-handle">

<img class="thumbnail" width="50" height="50" src="<?php echo $html->url("/wildflower/thumbnail/{$file['Asset']['name']}/50/50/1"); ?>" alt="<?php echo $file['Asset']['name']; ?>" />
<img class="thumbnail" width="50" height="50" src="<?php echo $html->url("/$mprefix/thumbnail/{$file['Asset']['name']}/50/50/1"); ?>" alt="<?php echo $file['Asset']['name']; ?>" />

<h3><?php echo hsc($file['Asset']['name']); ?></h3>

Expand All @@ -28,9 +30,16 @@

<div id="resize_image">
<h5>Resize</h5>
Width: <input type="text" id="resize_x" name="data[Resize][width]" size="4"> px&nbsp;&nbsp; Height: <input type="text" name="data[Resize][height]" id="resize_y" size="4"> px
Width: <input type="text" id="resize_x" name="data[Resize][width]" size="4"> px&nbsp;&nbsp; Height: <input type="text" name="data[Resize][height]" id="resize_y" size="4" /> px
</div>

<!-- div id="image_meta">
<h5>Alt</h5>
Alternative Text: <input type="text" id="meta_alt" name="data[Meta][alt]" size="75" />
<h5>Class</h5>
Class: <input type="text" name="data[Meta][class]" id="meta_class" size="4" />
</div -->

<span class="cleaner"></span>
<button id="insert_image">Insert selected image</button>
<span class="cleaner"></span>
Expand Down
3 changes: 2 additions & 1 deletion wildflower/views/layouts/admin_default.ctp
Expand Up @@ -38,7 +38,8 @@
action: '<?php echo $this->params['action'] ?>',
prefix: '<?php echo $prefix; ?>',
custom: {
wildflowerUploads: '<?php echo Configure::read('Wildflower.uploadsDirectoryName'); ?>'
wildflowerUploads: '<?php echo Configure::read('Wildflower.uploadsDirectoryName'); ?>',
wildflowerMPreix: '<?php echo Configure::read('Wildflower.mediaRoute'); ?>'
}
});

Expand Down
3 changes: 2 additions & 1 deletion wildflower/views/pages/admin_custom_fields.ctp
Expand Up @@ -9,10 +9,11 @@
if (empty($customFields)) {
echo '<p>', __('This page has no custom fields defined.', true), '</p>';
} else {
$mprefix = Configure::read('Wildflower.mediaRoute');
foreach ($customFields as $field) {
echo $form->input($field['name'], array('type' => $field['type'], 'value' => $field['value'], 'between' => '<br />'));
if ($field['type'] == 'file' and !empty($field['value'])) {
echo '<img width="80" height="80" src="', $html->url("/wildflower/thumbnail/{$field['value']}/80/80/1"), '" alt="" />';
echo '<img width="80" height="80" src="', $html->url("/$mprefix/thumbnail/{$field['value']}/80/80/1"), '" alt="" />';
}
}
}
Expand Down

0 comments on commit 8a43327

Please sign in to comment.