Skip to content
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

Cloning an image that ends with -0 in the filename does not work #556

Closed
td-marc opened this issue Mar 30, 2018 · 2 comments
Closed

Cloning an image that ends with -0 in the filename does not work #556

td-marc opened this issue Mar 30, 2018 · 2 comments

Comments

@td-marc
Copy link

td-marc commented Mar 30, 2018

Short description of the issue

I use the API to copy an image from one field to another on the same page. Like so:

   // Get the image we want to copy.
   $original = $page->images;
   $file = $original->getFile($original->first()->basename);
   // Clone that image and append it to the image_thumb field.
   $new = $original->clone($page->images->first(), array('action' => 'append', 'pagefiles' => $page->image_thumb));
   $page->save();

Expected behavior

First image from field 'images' should be copied to field 'image_thumb'.

Actual behavior

If the image has a filename like myimage-0.jpg, nothing is cloned.

Optional: Suggestion for a possible fix

In \wire\core\Pagefiles.php, if the script encounters a file that ends with -0, turn it into -1. On line 495 I added this small fix:

if ($n === 0) $n = 1;

Steps to reproduce the issue

  1. Upload a file/image that ends with -0 in the filename.
  2. Use the API to clone that file.

Setup/Environment

  • ProcessWire version: 3.0.96
ryancramerdesign added a commit to processwire/processwire that referenced this issue Apr 6, 2018
@ryancramerdesign
Copy link
Member

Thanks, I've pushed your suggested fix to this.

jdiderik added a commit to jdiderik/processwire that referenced this issue Apr 11, 2018
* 'master' of https://github.com/processwire/processwire:
  Bump version to 3.0.98
  Update InputfieldSelect::addOptionsString() to allow for user-defined disabled option if line in option string is prefixed with "disabled:"
  Make Inputfield requiredLabel customizable per field from API via $inputfield->requiredLabel property, to provide option to override default "missing requird value" label.
  Followup fix for issue processwire/processwire-issues#322 check for duplicate non-default language page name when creating new page
  Fix issue processwire/processwire-issues#558 remove unused filemtime() call in ProcessLanguage.module
  Fix issue processwire/processwire-issues#556 fix issue when cloning Pagefile that has name ending with "-0".
  Fix issue processwire/proceswire-issues#555 in ProcessProfile where 50% width Inputfield followed by submit button resulted in submit button in wrong position
  Bump to 3.0.97 and update to add a Pagefile::HTTPURL to accompany the existing Pagefile::URL property (uppercase implies cache busting URLs).
  Attempt to fix issue processwire/processwire-issues#554 isue with $files->include() and Windows paths
  Fix issue processwire/processwire-issues#553 where a note in AdminThemeUikit config screen needed to be updated for new module location
  Fix issue processwire/processwire-issues#277 where Inputfield::collapsedNever constant didn't work quite right in some cases
  Fix issue processwire/processwire-issues#544 where FieldsetTab in User editor was not viewable to non-superuser with user-admin permission
  Fix issue processwire/processwire-issues#551 Pages::trashed and Pages::restored hooks were getting called twice
  Fix issue processwire/processwire-issues#548 WireLog::getLines method wasn't passing options array to FileLog::find
  Fix issue in ProcessCommentsManager where the tabs were not showing active state properly in AdminThemeUikit. Plus some minor CSS updates in InputfieldPage and ProcessPageLister.
  Update FieldtypePage to support a runtime option to create Page references that don't exist when value is set by title. This is to accommodate a feature in ImportPagesCSV module.
  Update FieldtypeInteger so that it will still convert to integer even if number prefixed with USD or EUR symbol.
  Prevent stars input from showing in InputfieldCommentsAdmin.module when stars feature is not enabled
@netcarver
Copy link
Collaborator

@td-marc Hello. Could you close this issue if it is resolved to your satisfaction. Thank you!

@td-marc td-marc closed this as completed Jul 25, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants